{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE DisambiguateRecordFields #-}
{-# LANGUAGE EmptyCase #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
module Cardano.Api.Tx.Body
( parseTxId
, TxBody (.., TxBody)
, createTransactionBody
, createAndValidateTransactionBody
, TxBodyContent (..)
, makeByronTransactionBody
, defaultTxBodyContent
, defaultTxFee
, defaultTxValidityUpperBound
, setTxIns
, modTxIns
, addTxIn
, addTxIns
, setTxInsCollateral
, modTxInsCollateral
, addTxInsCollateral
, addTxInCollateral
, setTxInsReference
, modTxInsReference
, addTxInsReference
, addTxInReference
, setTxOuts
, modTxOuts
, addTxOut
, addTxOuts
, setTxTotalCollateral
, modTxTotalCollateral
, setTxReturnCollateral
, modTxReturnCollateral
, setTxFee
, modTxFee
, setTxValidityLowerBound
, modTxValidityLowerBound
, setTxValidityUpperBound
, modTxValidityUpperBound
, setTxMetadata
, modTxMetadata
, setTxAuxScripts
, modTxAuxScripts
, setTxExtraKeyWits
, modTxExtraKeyWits
, addTxExtraKeyWits
, setTxProtocolParams
, setTxWithdrawals
, modTxWithdrawals
, setTxCertificates
, modTxCertificates
, setTxUpdateProposal
, modTxUpdateProposal
, setTxProposalProcedures
, setTxVotingProcedures
, setTxMintValue
, modTxMintValue
, addTxMintValue
, subtractTxMintValue
, setTxScriptValidity
, modTxScriptValidity
, setTxCurrentTreasuryValue
, setTxTreasuryDonation
, TxBodyError (..)
, TxBodyScriptData (..)
, TxScriptValidity (..)
, ScriptValidity (..)
, scriptValidityToIsValid
, isValidToScriptValidity
, txScriptValidityToIsValid
, txScriptValidityToScriptValidity
, TxId (..)
, getTxId
, getTxIdByron
, getTxIdShelley
, TxIn (..)
, TxIns
, indexTxIns
, TxIx (..)
, genesisUTxOPseudoTxIn
, getReferenceInputsSizeForTxIds
, CtxTx
, CtxUTxO
, TxOut (..)
, TxOutValue (..)
, TxOutDatum (TxOutDatumNone, TxOutDatumHash, TxOutSupplementalDatum, TxOutDatumInline)
, toCtxUTxOTxOut
, lovelaceToTxOutValue
, prettyRenderTxOut
, txOutValueToLovelace
, txOutValueToValue
, parseHash
, TxOutInAnyEra (..)
, txOutInAnyEra
, TxInsCollateral (..)
, TxInsReference (..)
, TxReturnCollateral (..)
, TxTotalCollateral (..)
, TxFee (..)
, TxValidityLowerBound (..)
, TxValidityUpperBound (..)
, TxMetadataInEra (..)
, TxAuxScripts (..)
, TxExtraKeyWitnesses (..)
, TxWithdrawals (..)
, indexTxWithdrawals
, TxCertificates (..)
, indexTxCertificates
, TxUpdateProposal (..)
, TxMintValue (..)
, txMintValueToValue
, indexTxMintValue
, TxVotingProcedures (..)
, mkTxVotingProcedures
, indexTxVotingProcedures
, TxProposalProcedures (..)
, mkTxProposalProcedures
, indexTxProposalProcedures
, convProposalProcedures
, BuildTxWith (..)
, BuildTx
, ViewTx
, buildTxWithToMaybe
, AnyScriptWitness (..)
, ScriptWitnessIndex (..)
, renderScriptWitnessIndex
, collectTxBodyScriptWitnesses
, toScriptIndex
, scriptDataToInlineDatum
, convCertificates
, convCollateralTxIns
, convExtraKeyWitnesses
, convLanguages
, convMintValue
, convReferenceInputs
, convReturnCollateral
, convScripts
, convScriptData
, convTotalCollateral
, convTransactionFee
, convTxIns
, convTxOuts
, convTxUpdateProposal
, convValidityLowerBound
, convValidityUpperBound
, convVotingProcedures
, convWithdrawals
, getScriptIntegrityHash
, mkCommonTxBody
, toAuxiliaryData
, toByronTxId
, toShelleyTxId
, toShelleyTxIn
, toShelleyTxOut
, toShelleyTxOutAny
, fromShelleyTxId
, fromShelleyTxIn
, fromShelleyTxOut
, fromByronTxIn
, fromLedgerTxOuts
, renderTxIn
, calculateExecutionUnitsLovelace
, AsType (AsTxId, AsTxBody, AsByronTxBody, AsShelleyTxBody, AsMaryTxBody)
, getTxBodyContent
, validateTxIns
, guardShelleyTxInsOverflow
, validateTxOuts
, validateMetadata
, validateTxInsCollateral
, validateProtocolParameters
)
where
import Cardano.Api.Address
import Cardano.Api.Certificate
import Cardano.Api.Eon.AllegraEraOnwards
import Cardano.Api.Eon.AlonzoEraOnwards
import Cardano.Api.Eon.BabbageEraOnwards
import Cardano.Api.Eon.Convert
import Cardano.Api.Eon.ConwayEraOnwards
import Cardano.Api.Eon.MaryEraOnwards
import Cardano.Api.Eon.ShelleyBasedEra
import Cardano.Api.Eon.ShelleyToBabbageEra
import Cardano.Api.Eras.Case
import Cardano.Api.Eras.Core
import Cardano.Api.Error (Error (..), displayError)
import Cardano.Api.Feature
import Cardano.Api.Governance.Actions.VotingProcedure
import Cardano.Api.Hash
import Cardano.Api.Keys.Byron
import Cardano.Api.Keys.Shelley
import qualified Cardano.Api.Ledger.Lens as A
import Cardano.Api.NetworkId
import Cardano.Api.Pretty
import Cardano.Api.ProtocolParameters
import qualified Cardano.Api.ReexposeLedger as Ledger
import Cardano.Api.Script
import Cardano.Api.ScriptData
import Cardano.Api.SerialiseCBOR
import Cardano.Api.SerialiseJSON
import Cardano.Api.SerialiseRaw
import Cardano.Api.Tx.Sign
import Cardano.Api.TxIn
import Cardano.Api.TxMetadata
import Cardano.Api.Utils
import Cardano.Api.Value
import Cardano.Api.ValueParser
import qualified Cardano.Chain.Common as Byron
import qualified Cardano.Chain.UTxO as Byron
import qualified Cardano.Crypto.Hash.Class as Crypto
import qualified Cardano.Crypto.Hashing as Byron
import qualified Cardano.Ledger.Allegra.Core as L
import qualified Cardano.Ledger.Alonzo.Core as L
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import qualified Cardano.Ledger.Alonzo.Tx as Alonzo (hashScriptIntegrity)
import qualified Cardano.Ledger.Alonzo.TxWits as Alonzo
import qualified Cardano.Ledger.Api as L
import qualified Cardano.Ledger.Babbage.UTxO as L
import Cardano.Ledger.BaseTypes (StrictMaybe (..))
import Cardano.Ledger.Binary (Annotated (..))
import qualified Cardano.Ledger.Binary as CBOR
import qualified Cardano.Ledger.Coin as L
import qualified Cardano.Ledger.Conway.Core as L
import Cardano.Ledger.Core ()
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Ledger.Core as Ledger
import qualified Cardano.Ledger.Credential as Shelley
import Cardano.Ledger.Crypto (StandardCrypto)
import qualified Cardano.Ledger.Keys as Shelley
import Cardano.Ledger.Mary.Value as L (MaryValue (..), MultiAsset)
import qualified Cardano.Ledger.Plutus.Data as Plutus
import qualified Cardano.Ledger.Plutus.Language as Plutus
import qualified Cardano.Ledger.SafeHash as SafeHash
import qualified Cardano.Ledger.Shelley.API as Ledger
import qualified Cardano.Ledger.Shelley.Genesis as Shelley
import qualified Cardano.Ledger.Shelley.TxCert as Shelley
import qualified Cardano.Ledger.TxIn as L
import Cardano.Ledger.Val as L (isZero)
import Cardano.Slotting.Slot (SlotNo (..))
import Ouroboros.Consensus.Shelley.Eras (StandardAllegra, StandardAlonzo, StandardBabbage,
StandardConway, StandardMary, StandardShelley)
import Control.Applicative
import Control.Monad
import Data.Aeson (object, withObject, (.:), (.:?), (.=))
import qualified Data.Aeson as Aeson
import qualified Data.Aeson.Key as Aeson
import qualified Data.Aeson.Types as Aeson
import Data.Bifunctor (Bifunctor (..))
import Data.ByteString (ByteString)
import qualified Data.ByteString.Base16 as Base16
import qualified Data.ByteString.Char8 as BSC
import qualified Data.DList as DList
import Data.Foldable (for_)
import qualified Data.Foldable as Foldable
import Data.Function (on)
import Data.Functor (($>))
import Data.List (sortBy)
import qualified Data.List as List
import qualified Data.List.NonEmpty as NonEmpty
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
import Data.Maybe
import Data.Monoid
import Data.OSet.Strict (OSet, (|><))
import qualified Data.OSet.Strict as OSet
import Data.Scientific (toBoundedInteger)
import qualified Data.Sequence.Strict as Seq
import Data.Set (Set)
import qualified Data.Set as Set
import Data.String
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Data.Type.Equality
import Data.Typeable
import Data.Word (Word16, Word32, Word64)
import GHC.Exts (IsList (..))
import GHC.Stack
import Lens.Micro hiding (ix)
import Lens.Micro.Extras (view)
import qualified Text.Parsec as Parsec
import Text.Parsec ((<?>))
import qualified Text.Parsec.String as Parsec
data CtxTx
data CtxUTxO
data TxOut ctx era
= TxOut
(AddressInEra era)
(TxOutValue era)
(TxOutDatum ctx era)
(ReferenceScript era)
deriving instance Eq (TxOut ctx era)
deriving instance Show (TxOut ctx era)
data TxOutInAnyEra where
TxOutInAnyEra
:: CardanoEra era
-> TxOut CtxTx era
-> TxOutInAnyEra
deriving instance Show TxOutInAnyEra
instance Eq TxOutInAnyEra where
TxOutInAnyEra CardanoEra era
era1 TxOut CtxTx era
out1 == :: TxOutInAnyEra -> TxOutInAnyEra -> Bool
== TxOutInAnyEra CardanoEra era
era2 TxOut CtxTx era
out2 =
case CardanoEra era -> CardanoEra era -> Maybe (era :~: era)
forall a b. CardanoEra a -> CardanoEra b -> Maybe (a :~: b)
forall {k} (f :: k -> *) (a :: k) (b :: k).
TestEquality f =>
f a -> f b -> Maybe (a :~: b)
testEquality CardanoEra era
era1 CardanoEra era
era2 of
Just era :~: era
Refl -> TxOut CtxTx era
out1 TxOut CtxTx era -> TxOut CtxTx era -> Bool
forall a. Eq a => a -> a -> Bool
== TxOut CtxTx era
TxOut CtxTx era
out2
Maybe (era :~: era)
Nothing -> Bool
False
deriving via (ShowOf TxOutInAnyEra) instance Pretty TxOutInAnyEra
txOutInAnyEra :: CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
txOutInAnyEra :: forall era. CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
txOutInAnyEra = CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
forall era. CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
TxOutInAnyEra
toCtxUTxOTxOut :: TxOut CtxTx era -> TxOut CtxUTxO era
toCtxUTxOTxOut :: forall era. TxOut CtxTx era -> TxOut CtxUTxO era
toCtxUTxOTxOut (TxOut AddressInEra era
addr TxOutValue era
val TxOutDatum CtxTx era
d ReferenceScript era
refS) =
let dat :: TxOutDatum CtxUTxO era
dat = case TxOutDatum CtxTx era
d of
TxOutDatum CtxTx era
TxOutDatumNone -> TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
TxOutDatumHash AlonzoEraOnwards era
s Hash ScriptData
h -> AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum CtxUTxO era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
s Hash ScriptData
h
TxOutSupplementalDatum AlonzoEraOnwards era
s HashableScriptData
datum -> AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum CtxUTxO era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
s (Hash ScriptData -> TxOutDatum CtxUTxO era)
-> Hash ScriptData -> TxOutDatum CtxUTxO era
forall a b. (a -> b) -> a -> b
$ HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
datum
TxOutDatumInline BabbageEraOnwards era
s HashableScriptData
sd -> BabbageEraOnwards era
-> HashableScriptData -> TxOutDatum CtxUTxO era
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards era
s HashableScriptData
sd
in AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra era
addr TxOutValue era
val TxOutDatum CtxUTxO era
dat ReferenceScript era
refS
instance IsCardanoEra era => ToJSON (TxOut ctx era) where
toJSON :: TxOut ctx era -> Value
toJSON = CardanoEra era -> TxOut ctx era -> Value
forall era ctx. CardanoEra era -> TxOut ctx era -> Value
txOutToJsonValue CardanoEra era
forall era. IsCardanoEra era => CardanoEra era
cardanoEra
txOutToJsonValue :: CardanoEra era -> TxOut ctx era -> Aeson.Value
txOutToJsonValue :: forall era ctx. CardanoEra era -> TxOut ctx era -> Value
txOutToJsonValue CardanoEra era
era (TxOut AddressInEra era
addr TxOutValue era
val TxOutDatum ctx era
dat ReferenceScript era
refScript) =
case CardanoEra era
era of
CardanoEra era
ByronEra -> [Pair] -> Value
object [Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val]
CardanoEra era
ShelleyEra -> [Pair] -> Value
object [Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val]
CardanoEra era
AllegraEra -> [Pair] -> Value
object [Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val]
CardanoEra era
MaryEra -> [Pair] -> Value
object [Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val]
CardanoEra era
AlonzoEra ->
[Pair] -> Value
object
[ Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr
, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val
, TxOutDatum ctx era -> Pair
forall ctx era. TxOutDatum ctx era -> Pair
datHashJsonVal TxOutDatum ctx era
dat
, Key
"datum" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
datJsonVal TxOutDatum ctx era
dat
]
CardanoEra era
BabbageEra ->
[Pair] -> Value
object
[ Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr
, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val
, TxOutDatum ctx era -> Pair
forall ctx era. TxOutDatum ctx era -> Pair
datHashJsonVal TxOutDatum ctx era
dat
, Key
"datum" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
datJsonVal TxOutDatum ctx era
dat
, Key
"inlineDatum" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
inlineDatumJsonVal TxOutDatum ctx era
dat
, Key
"inlineDatumRaw" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
inlineDatumRawJsonCbor TxOutDatum ctx era
dat
, Key
"referenceScript" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReferenceScript era -> Value
forall era. ReferenceScript era -> Value
refScriptJsonVal ReferenceScript era
refScript
]
CardanoEra era
ConwayEra ->
[Pair] -> Value
object
[ Key
"address" Key -> AddressInEra era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= AddressInEra era
addr
, Key
"value" Key -> TxOutValue era -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutValue era
val
, TxOutDatum ctx era -> Pair
forall ctx era. TxOutDatum ctx era -> Pair
datHashJsonVal TxOutDatum ctx era
dat
, Key
"datum" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
datJsonVal TxOutDatum ctx era
dat
, Key
"inlineDatum" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
inlineDatumJsonVal TxOutDatum ctx era
dat
, Key
"inlineDatumRaw" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= TxOutDatum ctx era -> Value
forall ctx era. TxOutDatum ctx era -> Value
inlineDatumRawJsonCbor TxOutDatum ctx era
dat
, Key
"referenceScript" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= ReferenceScript era -> Value
forall era. ReferenceScript era -> Value
refScriptJsonVal ReferenceScript era
refScript
]
where
datHashJsonVal :: TxOutDatum ctx era -> Aeson.Pair
datHashJsonVal :: forall ctx era. TxOutDatum ctx era -> Pair
datHashJsonVal TxOutDatum ctx era
d =
case TxOutDatum ctx era
d of
TxOutDatum ctx era
TxOutDatumNone ->
Key
"datumhash" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value
Aeson.Null
TxOutDatumHash AlonzoEraOnwards era
_ Hash ScriptData
h ->
Key
"datumhash" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Hash ScriptData -> Value
forall a. ToJSON a => a -> Value
toJSON Hash ScriptData
h
TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
datum ->
Key
"datumhash" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Hash ScriptData -> Value
forall a. ToJSON a => a -> Value
toJSON (HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
datum)
TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
datum ->
Key
"inlineDatumhash" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Hash ScriptData -> Value
forall a. ToJSON a => a -> Value
toJSON (HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
datum)
datJsonVal :: TxOutDatum ctx era -> Aeson.Value
datJsonVal :: forall ctx era. TxOutDatum ctx era -> Value
datJsonVal TxOutDatum ctx era
d =
case TxOutDatum ctx era
d of
TxOutDatum ctx era
TxOutDatumNone -> Value
Aeson.Null
TxOutDatumHash AlonzoEraOnwards era
_ Hash ScriptData
_ -> Value
Aeson.Null
TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
datum -> ScriptDataJsonSchema -> HashableScriptData -> Value
scriptDataToJson ScriptDataJsonSchema
ScriptDataJsonDetailedSchema HashableScriptData
datum
TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
_ -> Value
Aeson.Null
inlineDatumJsonVal :: TxOutDatum ctx era -> Aeson.Value
inlineDatumJsonVal :: forall ctx era. TxOutDatum ctx era -> Value
inlineDatumJsonVal TxOutDatum ctx era
d =
case TxOutDatum ctx era
d of
TxOutDatum ctx era
TxOutDatumNone -> Value
Aeson.Null
TxOutDatumHash{} -> Value
Aeson.Null
TxOutSupplementalDatum{} -> Value
Aeson.Null
TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
datum -> ScriptDataJsonSchema -> HashableScriptData -> Value
scriptDataToJson ScriptDataJsonSchema
ScriptDataJsonDetailedSchema HashableScriptData
datum
inlineDatumRawJsonCbor :: TxOutDatum ctx era -> Aeson.Value
inlineDatumRawJsonCbor :: forall ctx era. TxOutDatum ctx era -> Value
inlineDatumRawJsonCbor TxOutDatum ctx era
d =
case TxOutDatum ctx era
d of
TxOutDatum ctx era
TxOutDatumNone -> Value
Aeson.Null
TxOutDatumHash{} -> Value
Aeson.Null
TxOutSupplementalDatum{} -> Value
Aeson.Null
TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
datum ->
Text -> Value
Aeson.String
(Text -> Value)
-> (HashableScriptData -> Text) -> HashableScriptData -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> Text
Text.decodeUtf8
(ByteString -> Text)
-> (HashableScriptData -> ByteString) -> HashableScriptData -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ByteString -> ByteString
Base16.encode
(ByteString -> ByteString)
-> (HashableScriptData -> ByteString)
-> HashableScriptData
-> ByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. HashableScriptData -> ByteString
forall a. SerialiseAsCBOR a => a -> ByteString
serialiseToCBOR
(HashableScriptData -> Value) -> HashableScriptData -> Value
forall a b. (a -> b) -> a -> b
$ HashableScriptData
datum
refScriptJsonVal :: ReferenceScript era -> Aeson.Value
refScriptJsonVal :: forall era. ReferenceScript era -> Value
refScriptJsonVal ReferenceScript era
rScript =
case ReferenceScript era
rScript of
ReferenceScript BabbageEraOnwards era
_ ScriptInAnyLang
s -> ScriptInAnyLang -> Value
forall a. ToJSON a => a -> Value
toJSON ScriptInAnyLang
s
ReferenceScript era
ReferenceScriptNone -> Value
Aeson.Null
instance IsShelleyBasedEra era => FromJSON (TxOut CtxTx era) where
parseJSON :: Value -> Parser (TxOut CtxTx era)
parseJSON = String
-> (Object -> Parser (TxOut CtxTx era))
-> Value
-> Parser (TxOut CtxTx era)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"TxOut" ((Object -> Parser (TxOut CtxTx era))
-> Value -> Parser (TxOut CtxTx era))
-> (Object -> Parser (TxOut CtxTx era))
-> Value
-> Parser (TxOut CtxTx era)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
case ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra :: ShelleyBasedEra era of
ShelleyBasedEra era
ShelleyBasedEraShelley ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutDatum CtxTx era)
-> Parser (ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxTx era -> Parser (TxOutDatum CtxTx era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxTx era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraMary ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutDatum CtxTx era)
-> Parser (ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxTx era -> Parser (TxOutDatum CtxTx era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxTx era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraAllegra ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutDatum CtxTx era)
-> Parser (ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxTx era -> Parser (TxOutDatum CtxTx era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxTx era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraAlonzo -> AlonzoEraOnwards era -> Object -> Parser (TxOut CtxTx era)
alonzoTxOutParser AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo Object
o
ShelleyBasedEra era
ShelleyBasedEraBabbage -> do
TxOut CtxTx era
alonzoTxOutInBabbage <- AlonzoEraOnwards era -> Object -> Parser (TxOut CtxTx era)
alonzoTxOutParser AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage Object
o
Maybe (Hash ScriptData)
inlineDatumHash <- Object
o Object -> Key -> Parser (Maybe (Hash ScriptData))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatumhash"
Maybe Value
inlineDatum <- Object
o Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatum"
TxOutDatum CtxTx BabbageEra
mInlineDatum <-
case (Maybe Value
inlineDatum, Maybe (Hash ScriptData)
inlineDatumHash) of
(Just Value
dVal, Just Hash ScriptData
h) -> do
case ScriptDataJsonSchema
-> Value -> Either ScriptDataJsonBytesError HashableScriptData
scriptDataJsonToHashable ScriptDataJsonSchema
ScriptDataJsonDetailedSchema Value
dVal of
Left ScriptDataJsonBytesError
err ->
String -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOutDatum CtxTx BabbageEra))
-> String -> Parser (TxOutDatum CtxTx BabbageEra)
forall a b. (a -> b) -> a -> b
$ String
"Error parsing TxOut JSON: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ScriptDataJsonBytesError -> String
forall a. Error a => a -> String
displayError ScriptDataJsonBytesError
err
Right HashableScriptData
hashableData -> do
if HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
hashableData Hash ScriptData -> Hash ScriptData -> Bool
forall a. Eq a => a -> a -> Bool
/= Hash ScriptData
h
then String -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Inline datum not equivalent to inline datum hash"
else TxOutDatum CtxTx BabbageEra -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOutDatum CtxTx BabbageEra
-> Parser (TxOutDatum CtxTx BabbageEra))
-> TxOutDatum CtxTx BabbageEra
-> Parser (TxOutDatum CtxTx BabbageEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards BabbageEra
-> HashableScriptData -> TxOutDatum CtxTx BabbageEra
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage HashableScriptData
hashableData
(Maybe Value
Nothing, Maybe (Hash ScriptData)
Nothing) -> TxOutDatum CtxTx BabbageEra -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx BabbageEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
(Maybe Value
_, Maybe (Hash ScriptData)
_) ->
String -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
String
"Should not be possible to create a tx output with either an inline datum hash or an inline datum"
Maybe ScriptInAnyLang
mReferenceScript <- Object
o Object -> Key -> Parser (Maybe ScriptInAnyLang)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"referenceScript"
TxOut CtxTx BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxTx BabbageEra)
reconcileBabbage TxOut CtxTx era
TxOut CtxTx BabbageEra
alonzoTxOutInBabbage TxOutDatum CtxTx BabbageEra
mInlineDatum Maybe ScriptInAnyLang
mReferenceScript
ShelleyBasedEra era
ShelleyBasedEraConway -> do
TxOut CtxTx era
alonzoTxOutInConway <- AlonzoEraOnwards era -> Object -> Parser (TxOut CtxTx era)
alonzoTxOutParser AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway Object
o
Maybe (Hash ScriptData)
inlineDatumHash <- Object
o Object -> Key -> Parser (Maybe (Hash ScriptData))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatumhash"
Maybe Value
inlineDatum <- Object
o Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatum"
TxOutDatum CtxTx ConwayEra
mInlineDatum <-
case (Maybe Value
inlineDatum, Maybe (Hash ScriptData)
inlineDatumHash) of
(Just Value
dVal, Just Hash ScriptData
h) ->
case ScriptDataJsonSchema
-> Value -> Either ScriptDataJsonError HashableScriptData
scriptDataFromJson ScriptDataJsonSchema
ScriptDataJsonDetailedSchema Value
dVal of
Left ScriptDataJsonError
err ->
String -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOutDatum CtxTx ConwayEra))
-> String -> Parser (TxOutDatum CtxTx ConwayEra)
forall a b. (a -> b) -> a -> b
$ String
"Error parsing TxOut JSON: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ScriptDataJsonError -> String
forall a. Error a => a -> String
displayError ScriptDataJsonError
err
Right HashableScriptData
sData ->
if HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
sData Hash ScriptData -> Hash ScriptData -> Bool
forall a. Eq a => a -> a -> Bool
/= Hash ScriptData
h
then String -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Inline datum not equivalent to inline datum hash"
else TxOutDatum CtxTx ConwayEra -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOutDatum CtxTx ConwayEra -> Parser (TxOutDatum CtxTx ConwayEra))
-> TxOutDatum CtxTx ConwayEra
-> Parser (TxOutDatum CtxTx ConwayEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards ConwayEra
-> HashableScriptData -> TxOutDatum CtxTx ConwayEra
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway HashableScriptData
sData
(Maybe Value
Nothing, Maybe (Hash ScriptData)
Nothing) -> TxOutDatum CtxTx ConwayEra -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx ConwayEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
(Maybe Value
_, Maybe (Hash ScriptData)
_) ->
String -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
String
"Should not be possible to create a tx output with either an inline datum hash or an inline datum"
Maybe ScriptInAnyLang
mReferenceScript <- Object
o Object -> Key -> Parser (Maybe ScriptInAnyLang)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"referenceScript"
TxOut CtxTx ConwayEra
-> TxOutDatum CtxTx ConwayEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxTx ConwayEra)
reconcileConway TxOut CtxTx era
TxOut CtxTx ConwayEra
alonzoTxOutInConway TxOutDatum CtxTx ConwayEra
mInlineDatum Maybe ScriptInAnyLang
mReferenceScript
where
reconcileBabbage
:: TxOut CtxTx BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> Maybe ScriptInAnyLang
-> Aeson.Parser (TxOut CtxTx BabbageEra)
reconcileBabbage :: TxOut CtxTx BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxTx BabbageEra)
reconcileBabbage top :: TxOut CtxTx BabbageEra
top@(TxOut AddressInEra BabbageEra
addr TxOutValue BabbageEra
v TxOutDatum CtxTx BabbageEra
dat ReferenceScript BabbageEra
r) TxOutDatum CtxTx BabbageEra
babbageDatum Maybe ScriptInAnyLang
mBabRefScript = do
TxOutDatum CtxTx BabbageEra
finalDat <- case (TxOutDatum CtxTx BabbageEra
dat, TxOutDatum CtxTx BabbageEra
babbageDatum) of
(TxOutDatum CtxTx BabbageEra
TxOutDatumNone, TxOutDatum CtxTx BabbageEra
bDatum) -> TxOutDatum CtxTx BabbageEra -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx BabbageEra
bDatum
(TxOutDatum CtxTx BabbageEra
anyDat, TxOutDatum CtxTx BabbageEra
TxOutDatumNone) -> TxOutDatum CtxTx BabbageEra -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx BabbageEra
anyDat
(TxOutDatum CtxTx BabbageEra
alonzoDat, TxOutDatum CtxTx BabbageEra
babbageDat) ->
String -> Parser (TxOutDatum CtxTx BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOutDatum CtxTx BabbageEra))
-> String -> Parser (TxOutDatum CtxTx BabbageEra)
forall a b. (a -> b) -> a -> b
$
String
"Parsed an Alonzo era datum and a Babbage era datum "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"TxOut: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> TxOut CtxTx BabbageEra -> String
forall a. Show a => a -> String
show TxOut CtxTx BabbageEra
top
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"Alonzo datum: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> TxOutDatum CtxTx BabbageEra -> String
forall a. Show a => a -> String
show TxOutDatum CtxTx BabbageEra
alonzoDat
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"Babbage dat: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> TxOutDatum CtxTx BabbageEra -> String
forall a. Show a => a -> String
show TxOutDatum CtxTx BabbageEra
babbageDat
ReferenceScript BabbageEra
finalRefScript <- case Maybe ScriptInAnyLang
mBabRefScript of
Maybe ScriptInAnyLang
Nothing -> ReferenceScript BabbageEra -> Parser (ReferenceScript BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript BabbageEra
r
Just ScriptInAnyLang
anyScript ->
ReferenceScript BabbageEra -> Parser (ReferenceScript BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ReferenceScript BabbageEra -> Parser (ReferenceScript BabbageEra))
-> ReferenceScript BabbageEra
-> Parser (ReferenceScript BabbageEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards BabbageEra
-> ScriptInAnyLang -> ReferenceScript BabbageEra
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
ReferenceScript BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage ScriptInAnyLang
anyScript
TxOut CtxTx BabbageEra -> Parser (TxOut CtxTx BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOut CtxTx BabbageEra -> Parser (TxOut CtxTx BabbageEra))
-> TxOut CtxTx BabbageEra -> Parser (TxOut CtxTx BabbageEra)
forall a b. (a -> b) -> a -> b
$ AddressInEra BabbageEra
-> TxOutValue BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxTx BabbageEra
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra BabbageEra
addr TxOutValue BabbageEra
v TxOutDatum CtxTx BabbageEra
finalDat ReferenceScript BabbageEra
finalRefScript
reconcileConway
:: TxOut CtxTx ConwayEra
-> TxOutDatum CtxTx ConwayEra
-> Maybe ScriptInAnyLang
-> Aeson.Parser (TxOut CtxTx ConwayEra)
reconcileConway :: TxOut CtxTx ConwayEra
-> TxOutDatum CtxTx ConwayEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxTx ConwayEra)
reconcileConway top :: TxOut CtxTx ConwayEra
top@(TxOut AddressInEra ConwayEra
addr TxOutValue ConwayEra
v TxOutDatum CtxTx ConwayEra
dat ReferenceScript ConwayEra
r) TxOutDatum CtxTx ConwayEra
babbageDatum Maybe ScriptInAnyLang
mBabRefScript = do
TxOutDatum CtxTx ConwayEra
finalDat <- case (TxOutDatum CtxTx ConwayEra
dat, TxOutDatum CtxTx ConwayEra
babbageDatum) of
(TxOutDatum CtxTx ConwayEra
TxOutDatumNone, TxOutDatum CtxTx ConwayEra
bDatum) -> TxOutDatum CtxTx ConwayEra -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx ConwayEra
bDatum
(TxOutDatum CtxTx ConwayEra
anyDat, TxOutDatum CtxTx ConwayEra
TxOutDatumNone) -> TxOutDatum CtxTx ConwayEra -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx ConwayEra
anyDat
(TxOutDatum CtxTx ConwayEra
alonzoDat, TxOutDatum CtxTx ConwayEra
babbageDat) ->
String -> Parser (TxOutDatum CtxTx ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOutDatum CtxTx ConwayEra))
-> String -> Parser (TxOutDatum CtxTx ConwayEra)
forall a b. (a -> b) -> a -> b
$
String
"Parsed an Alonzo era datum and a Conway era datum "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"TxOut: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> TxOut CtxTx ConwayEra -> String
forall a. Show a => a -> String
show TxOut CtxTx ConwayEra
top
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"Alonzo datum: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> TxOutDatum CtxTx ConwayEra -> String
forall a. Show a => a -> String
show TxOutDatum CtxTx ConwayEra
alonzoDat
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"Conway dat: "
String -> ShowS
forall a. Semigroup a => a -> a -> a
<> TxOutDatum CtxTx ConwayEra -> String
forall a. Show a => a -> String
show TxOutDatum CtxTx ConwayEra
babbageDat
ReferenceScript ConwayEra
finalRefScript <- case Maybe ScriptInAnyLang
mBabRefScript of
Maybe ScriptInAnyLang
Nothing -> ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript ConwayEra
r
Just ScriptInAnyLang
anyScript ->
ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra))
-> ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards ConwayEra
-> ScriptInAnyLang -> ReferenceScript ConwayEra
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
ReferenceScript BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway ScriptInAnyLang
anyScript
TxOut CtxTx ConwayEra -> Parser (TxOut CtxTx ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOut CtxTx ConwayEra -> Parser (TxOut CtxTx ConwayEra))
-> TxOut CtxTx ConwayEra -> Parser (TxOut CtxTx ConwayEra)
forall a b. (a -> b) -> a -> b
$ AddressInEra ConwayEra
-> TxOutValue ConwayEra
-> TxOutDatum CtxTx ConwayEra
-> ReferenceScript ConwayEra
-> TxOut CtxTx ConwayEra
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra ConwayEra
addr TxOutValue ConwayEra
v TxOutDatum CtxTx ConwayEra
finalDat ReferenceScript ConwayEra
finalRefScript
alonzoTxOutParser
:: AlonzoEraOnwards era -> Aeson.Object -> Aeson.Parser (TxOut CtxTx era)
alonzoTxOutParser :: AlonzoEraOnwards era -> Object -> Parser (TxOut CtxTx era)
alonzoTxOutParser AlonzoEraOnwards era
w Object
o = do
Maybe (Hash ScriptData)
mDatumHash <- Object
o Object -> Key -> Parser (Maybe (Hash ScriptData))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"datumhash"
Maybe Value
mDatumVal <- Object
o Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"datum"
case (Maybe Value
mDatumVal, Maybe (Hash ScriptData)
mDatumHash) of
(Maybe Value
Nothing, Maybe (Hash ScriptData)
Nothing) ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutDatum CtxTx era)
-> Parser (ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxTx era -> Parser (TxOutDatum CtxTx era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxTx era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
(Just Value
dVal, Just{}) -> do
case ScriptDataJsonSchema
-> Value -> Either ScriptDataJsonBytesError HashableScriptData
scriptDataJsonToHashable ScriptDataJsonSchema
ScriptDataJsonDetailedSchema Value
dVal of
Left ScriptDataJsonBytesError
e -> String -> Parser (TxOut CtxTx era)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOut CtxTx era))
-> String -> Parser (TxOut CtxTx era)
forall a b. (a -> b) -> a -> b
$ String
"Error parsing ScriptData: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ScriptDataJsonBytesError -> String
forall a. Show a => a -> String
show ScriptDataJsonBytesError
e
Right HashableScriptData
hashableData ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutDatum CtxTx era)
-> Parser (ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxTx era -> Parser (TxOutDatum CtxTx era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
forall era.
AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
TxOutSupplementalDatum AlonzoEraOnwards era
w HashableScriptData
hashableData)
Parser (ReferenceScript era -> TxOut CtxTx era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
(Maybe Value
Nothing, Just Hash ScriptData
dHash) ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxTx era -> ReferenceScript era -> TxOut CtxTx era)
-> Parser (TxOutDatum CtxTx era)
-> Parser (ReferenceScript era -> TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxTx era -> Parser (TxOutDatum CtxTx era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum CtxTx era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
w Hash ScriptData
dHash)
Parser (ReferenceScript era -> TxOut CtxTx era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxTx era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
(Just Value
_dVal, Maybe (Hash ScriptData)
Nothing) -> String -> Parser (TxOut CtxTx era)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Only datum JSON was found, this should not be possible."
instance IsShelleyBasedEra era => FromJSON (TxOut CtxUTxO era) where
parseJSON :: Value -> Parser (TxOut CtxUTxO era)
parseJSON = String
-> (Object -> Parser (TxOut CtxUTxO era))
-> Value
-> Parser (TxOut CtxUTxO era)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"TxOut" ((Object -> Parser (TxOut CtxUTxO era))
-> Value -> Parser (TxOut CtxUTxO era))
-> (Object -> Parser (TxOut CtxUTxO era))
-> Value
-> Parser (TxOut CtxUTxO era)
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
case ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra :: ShelleyBasedEra era of
ShelleyBasedEra era
ShelleyBasedEraShelley ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (TxOutDatum CtxUTxO era)
-> Parser (ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxUTxO era -> Parser (TxOutDatum CtxUTxO era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraMary ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (TxOutDatum CtxUTxO era)
-> Parser (ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxUTxO era -> Parser (TxOutDatum CtxUTxO era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraAllegra ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (TxOutDatum CtxUTxO era)
-> Parser (ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxUTxO era -> Parser (TxOutDatum CtxUTxO era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraAlonzo -> AlonzoEraOnwards era -> Object -> Parser (TxOut CtxUTxO era)
alonzoTxOutParser AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo Object
o
ShelleyBasedEra era
ShelleyBasedEraBabbage -> do
TxOut CtxUTxO era
alonzoTxOutInBabbage <- AlonzoEraOnwards era -> Object -> Parser (TxOut CtxUTxO era)
alonzoTxOutParser AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage Object
o
Maybe (Hash ScriptData)
inlineDatumHash <- Object
o Object -> Key -> Parser (Maybe (Hash ScriptData))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatumhash"
Maybe Value
inlineDatum <- Object
o Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatum"
TxOutDatum CtxUTxO BabbageEra
mInlineDatum <-
case (Maybe Value
inlineDatum, Maybe (Hash ScriptData)
inlineDatumHash) of
(Just Value
dVal, Just Hash ScriptData
h) -> do
case ScriptDataJsonSchema
-> Value -> Either ScriptDataJsonBytesError HashableScriptData
scriptDataJsonToHashable ScriptDataJsonSchema
ScriptDataJsonDetailedSchema Value
dVal of
Left ScriptDataJsonBytesError
err ->
String -> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOutDatum CtxUTxO BabbageEra))
-> String -> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a b. (a -> b) -> a -> b
$ String
"Error parsing TxOut JSON: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ScriptDataJsonBytesError -> String
forall a. Error a => a -> String
displayError ScriptDataJsonBytesError
err
Right HashableScriptData
hashableData -> do
if HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
hashableData Hash ScriptData -> Hash ScriptData -> Bool
forall a. Eq a => a -> a -> Bool
/= Hash ScriptData
h
then String -> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Inline datum not equivalent to inline datum hash"
else TxOutDatum CtxUTxO BabbageEra
-> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOutDatum CtxUTxO BabbageEra
-> Parser (TxOutDatum CtxUTxO BabbageEra))
-> TxOutDatum CtxUTxO BabbageEra
-> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards BabbageEra
-> HashableScriptData -> TxOutDatum CtxUTxO BabbageEra
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage HashableScriptData
hashableData
(Maybe Value
Nothing, Maybe (Hash ScriptData)
Nothing) -> TxOutDatum CtxUTxO BabbageEra
-> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO BabbageEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
(Maybe Value
_, Maybe (Hash ScriptData)
_) ->
String -> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
String
"Should not be possible to create a tx output with either an inline datum hash or an inline datum"
Maybe ScriptInAnyLang
mReferenceScript <- Object
o Object -> Key -> Parser (Maybe ScriptInAnyLang)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"referenceScript"
TxOut CtxUTxO BabbageEra
-> TxOutDatum CtxUTxO BabbageEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxUTxO BabbageEra)
reconcileBabbage TxOut CtxUTxO era
TxOut CtxUTxO BabbageEra
alonzoTxOutInBabbage TxOutDatum CtxUTxO BabbageEra
mInlineDatum Maybe ScriptInAnyLang
mReferenceScript
ShelleyBasedEra era
ShelleyBasedEraConway -> do
TxOut CtxUTxO era
alonzoTxOutInConway <- AlonzoEraOnwards era -> Object -> Parser (TxOut CtxUTxO era)
alonzoTxOutParser AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway Object
o
Maybe (Hash ScriptData)
inlineDatumHash <- Object
o Object -> Key -> Parser (Maybe (Hash ScriptData))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatumhash"
Maybe Value
inlineDatum <- Object
o Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inlineDatum"
TxOutDatum CtxUTxO ConwayEra
mInlineDatum <-
case (Maybe Value
inlineDatum, Maybe (Hash ScriptData)
inlineDatumHash) of
(Just Value
dVal, Just Hash ScriptData
h) ->
case ScriptDataJsonSchema
-> Value -> Either ScriptDataJsonError HashableScriptData
scriptDataFromJson ScriptDataJsonSchema
ScriptDataJsonDetailedSchema Value
dVal of
Left ScriptDataJsonError
err ->
String -> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (TxOutDatum CtxUTxO ConwayEra))
-> String -> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a b. (a -> b) -> a -> b
$ String
"Error parsing TxOut JSON: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> ScriptDataJsonError -> String
forall a. Error a => a -> String
displayError ScriptDataJsonError
err
Right HashableScriptData
sData ->
if HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
sData Hash ScriptData -> Hash ScriptData -> Bool
forall a. Eq a => a -> a -> Bool
/= Hash ScriptData
h
then String -> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Inline datum not equivalent to inline datum hash"
else TxOutDatum CtxUTxO ConwayEra
-> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOutDatum CtxUTxO ConwayEra
-> Parser (TxOutDatum CtxUTxO ConwayEra))
-> TxOutDatum CtxUTxO ConwayEra
-> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards ConwayEra
-> HashableScriptData -> TxOutDatum CtxUTxO ConwayEra
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway HashableScriptData
sData
(Maybe Value
Nothing, Maybe (Hash ScriptData)
Nothing) -> TxOutDatum CtxUTxO ConwayEra
-> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO ConwayEra
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
(Maybe Value
_, Maybe (Hash ScriptData)
_) ->
String -> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail
String
"Should not be possible to create a tx output with either an inline datum hash or an inline datum"
Maybe ScriptInAnyLang
mReferenceScript <- Object
o Object -> Key -> Parser (Maybe ScriptInAnyLang)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"referenceScript"
TxOut CtxUTxO ConwayEra
-> TxOutDatum CtxUTxO ConwayEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxUTxO ConwayEra)
reconcileConway TxOut CtxUTxO era
TxOut CtxUTxO ConwayEra
alonzoTxOutInConway TxOutDatum CtxUTxO ConwayEra
mInlineDatum Maybe ScriptInAnyLang
mReferenceScript
where
reconcileBabbage
:: TxOut CtxUTxO BabbageEra
-> TxOutDatum CtxUTxO BabbageEra
-> Maybe ScriptInAnyLang
-> Aeson.Parser (TxOut CtxUTxO BabbageEra)
reconcileBabbage :: TxOut CtxUTxO BabbageEra
-> TxOutDatum CtxUTxO BabbageEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxUTxO BabbageEra)
reconcileBabbage (TxOut AddressInEra BabbageEra
addr TxOutValue BabbageEra
v TxOutDatum CtxUTxO BabbageEra
dat ReferenceScript BabbageEra
r) TxOutDatum CtxUTxO BabbageEra
babbageDatum Maybe ScriptInAnyLang
mBabRefScript = do
TxOutDatum CtxUTxO BabbageEra
finalDat <- case (TxOutDatum CtxUTxO BabbageEra
dat, TxOutDatum CtxUTxO BabbageEra
babbageDatum) of
(TxOutDatum CtxUTxO BabbageEra
TxOutDatumNone, TxOutDatum CtxUTxO BabbageEra
bDatum) -> TxOutDatum CtxUTxO BabbageEra
-> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO BabbageEra
bDatum
(TxOutDatum CtxUTxO BabbageEra
anyDat, TxOutDatum CtxUTxO BabbageEra
TxOutDatumNone) -> TxOutDatum CtxUTxO BabbageEra
-> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO BabbageEra
anyDat
(TxOutDatum CtxUTxO BabbageEra
_, TxOutDatum CtxUTxO BabbageEra
_) -> String -> Parser (TxOutDatum CtxUTxO BabbageEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Parsed an Alonzo era datum and a Babbage era datum"
ReferenceScript BabbageEra
finalRefScript <- case Maybe ScriptInAnyLang
mBabRefScript of
Maybe ScriptInAnyLang
Nothing -> ReferenceScript BabbageEra -> Parser (ReferenceScript BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript BabbageEra
r
Just ScriptInAnyLang
anyScript ->
ReferenceScript BabbageEra -> Parser (ReferenceScript BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ReferenceScript BabbageEra -> Parser (ReferenceScript BabbageEra))
-> ReferenceScript BabbageEra
-> Parser (ReferenceScript BabbageEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards BabbageEra
-> ScriptInAnyLang -> ReferenceScript BabbageEra
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
ReferenceScript BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage ScriptInAnyLang
anyScript
TxOut CtxUTxO BabbageEra -> Parser (TxOut CtxUTxO BabbageEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOut CtxUTxO BabbageEra -> Parser (TxOut CtxUTxO BabbageEra))
-> TxOut CtxUTxO BabbageEra -> Parser (TxOut CtxUTxO BabbageEra)
forall a b. (a -> b) -> a -> b
$ AddressInEra BabbageEra
-> TxOutValue BabbageEra
-> TxOutDatum CtxUTxO BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxUTxO BabbageEra
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra BabbageEra
addr TxOutValue BabbageEra
v TxOutDatum CtxUTxO BabbageEra
finalDat ReferenceScript BabbageEra
finalRefScript
reconcileConway
:: TxOut CtxUTxO ConwayEra
-> TxOutDatum CtxUTxO ConwayEra
-> Maybe ScriptInAnyLang
-> Aeson.Parser (TxOut CtxUTxO ConwayEra)
reconcileConway :: TxOut CtxUTxO ConwayEra
-> TxOutDatum CtxUTxO ConwayEra
-> Maybe ScriptInAnyLang
-> Parser (TxOut CtxUTxO ConwayEra)
reconcileConway (TxOut AddressInEra ConwayEra
addr TxOutValue ConwayEra
v TxOutDatum CtxUTxO ConwayEra
dat ReferenceScript ConwayEra
r) TxOutDatum CtxUTxO ConwayEra
babbageDatum Maybe ScriptInAnyLang
mBabRefScript = do
TxOutDatum CtxUTxO ConwayEra
finalDat <- case (TxOutDatum CtxUTxO ConwayEra
dat, TxOutDatum CtxUTxO ConwayEra
babbageDatum) of
(TxOutDatum CtxUTxO ConwayEra
TxOutDatumNone, TxOutDatum CtxUTxO ConwayEra
bDatum) -> TxOutDatum CtxUTxO ConwayEra
-> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO ConwayEra
bDatum
(TxOutDatum CtxUTxO ConwayEra
anyDat, TxOutDatum CtxUTxO ConwayEra
TxOutDatumNone) -> TxOutDatum CtxUTxO ConwayEra
-> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO ConwayEra
anyDat
(TxOutDatum CtxUTxO ConwayEra
_, TxOutDatum CtxUTxO ConwayEra
_) -> String -> Parser (TxOutDatum CtxUTxO ConwayEra)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"Parsed an Alonzo era datum and a Conway era datum"
ReferenceScript ConwayEra
finalRefScript <- case Maybe ScriptInAnyLang
mBabRefScript of
Maybe ScriptInAnyLang
Nothing -> ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript ConwayEra
r
Just ScriptInAnyLang
anyScript ->
ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra))
-> ReferenceScript ConwayEra -> Parser (ReferenceScript ConwayEra)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards ConwayEra
-> ScriptInAnyLang -> ReferenceScript ConwayEra
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
ReferenceScript BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway ScriptInAnyLang
anyScript
TxOut CtxUTxO ConwayEra -> Parser (TxOut CtxUTxO ConwayEra)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxOut CtxUTxO ConwayEra -> Parser (TxOut CtxUTxO ConwayEra))
-> TxOut CtxUTxO ConwayEra -> Parser (TxOut CtxUTxO ConwayEra)
forall a b. (a -> b) -> a -> b
$ AddressInEra ConwayEra
-> TxOutValue ConwayEra
-> TxOutDatum CtxUTxO ConwayEra
-> ReferenceScript ConwayEra
-> TxOut CtxUTxO ConwayEra
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra ConwayEra
addr TxOutValue ConwayEra
v TxOutDatum CtxUTxO ConwayEra
finalDat ReferenceScript ConwayEra
finalRefScript
alonzoTxOutParser :: AlonzoEraOnwards era -> Aeson.Object -> Aeson.Parser (TxOut CtxUTxO era)
alonzoTxOutParser :: AlonzoEraOnwards era -> Object -> Parser (TxOut CtxUTxO era)
alonzoTxOutParser AlonzoEraOnwards era
w Object
o = do
Maybe (Hash ScriptData)
mDatumHash <- Object
o Object -> Key -> Parser (Maybe (Hash ScriptData))
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"datumhash"
case Maybe (Hash ScriptData)
mDatumHash of
Maybe (Hash ScriptData)
Nothing ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (TxOutDatum CtxUTxO era)
-> Parser (ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxUTxO era -> Parser (TxOutDatum CtxUTxO era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return TxOutDatum CtxUTxO era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
Parser (ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
Just Hash ScriptData
dHash ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (AddressInEra era)
-> Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (AddressInEra era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"address"
Parser
(TxOutValue era
-> TxOutDatum CtxUTxO era
-> ReferenceScript era
-> TxOut CtxUTxO era)
-> Parser (TxOutValue era)
-> Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (TxOutValue era)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
Parser
(TxOutDatum CtxUTxO era
-> ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (TxOutDatum CtxUTxO era)
-> Parser (ReferenceScript era -> TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutDatum CtxUTxO era -> Parser (TxOutDatum CtxUTxO era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum CtxUTxO era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
w Hash ScriptData
dHash)
Parser (ReferenceScript era -> TxOut CtxUTxO era)
-> Parser (ReferenceScript era) -> Parser (TxOut CtxUTxO era)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ReferenceScript era -> Parser (ReferenceScript era)
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
toByronTxOut :: TxOut ctx ByronEra -> Maybe Byron.TxOut
toByronTxOut :: forall ctx. TxOut ctx ByronEra -> Maybe TxOut
toByronTxOut = \case
TxOut (AddressInEra AddressTypeInEra addrtype ByronEra
ByronAddressInAnyEra (ByronAddress Address
addr)) (TxOutValueByron Coin
value) TxOutDatum ctx ByronEra
_ ReferenceScript ByronEra
_ ->
Address -> Lovelace -> TxOut
Byron.TxOut Address
addr (Lovelace -> TxOut) -> Maybe Lovelace -> Maybe TxOut
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Coin -> Maybe Lovelace
toByronLovelace Coin
value
TxOut (AddressInEra AddressTypeInEra addrtype ByronEra
ByronAddressInAnyEra (ByronAddress Address
_)) (TxOutValueShelleyBased ShelleyBasedEra ByronEra
w Value (ShelleyLedgerEra ByronEra)
_) TxOutDatum ctx ByronEra
_ ReferenceScript ByronEra
_ ->
case ShelleyBasedEra ByronEra
w of {}
TxOut (AddressInEra (ShelleyAddressInEra ShelleyBasedEra ByronEra
sbe) ShelleyAddress{}) TxOutValue ByronEra
_ TxOutDatum ctx ByronEra
_ ReferenceScript ByronEra
_ ->
case ShelleyBasedEra ByronEra
sbe of {}
toShelleyTxOut
:: forall era ledgerera
. HasCallStack
=> ShelleyLedgerEra era ~ ledgerera
=> ShelleyBasedEra era
-> TxOut CtxUTxO era
-> Ledger.TxOut ledgerera
toShelleyTxOut :: forall era ledgerera.
(HasCallStack, ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era -> TxOut CtxUTxO era -> TxOut ledgerera
toShelleyTxOut ShelleyBasedEra era
_ = \case
TxOut AddressInEra era
_ (TxOutValueByron Coin
_) TxOutDatum CtxUTxO era
_ ReferenceScript era
_ ->
String -> TxOut ledgerera
forall a. HasCallStack => String -> a
error String
"toShelleyTxOut: Expected a Shelley value"
TxOut AddressInEra era
addr (TxOutValueShelleyBased ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
value) TxOutDatum CtxUTxO era
txoutdata ReferenceScript era
refScript ->
(ShelleyToMaryEraConstraints era =>
ShelleyToMaryEra era -> TxOut ledgerera)
-> (AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era -> TxOut ledgerera)
-> ShelleyBasedEra era
-> TxOut ledgerera
forall era a.
(ShelleyToMaryEraConstraints era => ShelleyToMaryEra era -> a)
-> (AlonzoEraOnwardsConstraints era => AlonzoEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToMaryOrAlonzoEraOnwards
(TxOut ledgerera -> ShelleyToMaryEra era -> TxOut ledgerera
forall a b. a -> b -> a
const (TxOut ledgerera -> ShelleyToMaryEra era -> TxOut ledgerera)
-> TxOut ledgerera -> ShelleyToMaryEra era -> TxOut ledgerera
forall a b. (a -> b) -> a -> b
$ Addr (EraCrypto ledgerera) -> Value ledgerera -> TxOut ledgerera
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value ledgerera
Value (ShelleyLedgerEra era)
value)
( \case
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo ->
Addr (EraCrypto (AlonzoEra StandardCrypto))
-> Value (AlonzoEra StandardCrypto)
-> TxOut (AlonzoEra StandardCrypto)
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value (AlonzoEra StandardCrypto)
Value (ShelleyLedgerEra era)
value
TxOut (AlonzoEra StandardCrypto)
-> (TxOut (AlonzoEra StandardCrypto) -> TxOut ledgerera)
-> TxOut ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Identity
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))))
-> TxOut (AlonzoEra StandardCrypto)
-> Identity (TxOut (AlonzoEra StandardCrypto))
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Identity
(StrictMaybe (SafeHash StandardCrypto EraIndependentData)))
-> TxOut (AlonzoEra StandardCrypto) -> Identity (TxOut ledgerera)
forall era.
AlonzoEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (DataHash (EraCrypto era)))
Lens'
(TxOut (AlonzoEra StandardCrypto))
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto))))
L.dataHashTxOutL ((StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Identity
(StrictMaybe (SafeHash StandardCrypto EraIndependentData)))
-> TxOut (AlonzoEra StandardCrypto) -> Identity (TxOut ledgerera))
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOut (AlonzoEra StandardCrypto)
-> TxOut ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxOutDatum CtxUTxO era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall era.
TxOutDatum CtxUTxO era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
toAlonzoTxOutDatumHashUTxO TxOutDatum CtxUTxO era
txoutdata
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage ->
Addr (EraCrypto StandardBabbage)
-> Value StandardBabbage -> TxOut StandardBabbage
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value StandardBabbage
Value (ShelleyLedgerEra era)
value
TxOut StandardBabbage
-> (TxOut StandardBabbage -> TxOut StandardBabbage)
-> TxOut StandardBabbage
forall a b. a -> (a -> b) -> b
& (Datum StandardBabbage -> Identity (Datum StandardBabbage))
-> TxOut StandardBabbage -> Identity (TxOut StandardBabbage)
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut StandardBabbage) (Datum StandardBabbage)
L.datumTxOutL ((Datum StandardBabbage -> Identity (Datum StandardBabbage))
-> TxOut StandardBabbage -> Identity (TxOut StandardBabbage))
-> Datum StandardBabbage
-> TxOut StandardBabbage
-> TxOut StandardBabbage
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxOutDatum CtxUTxO era -> Datum (ShelleyLedgerEra era)
forall era ctx.
(Era (ShelleyLedgerEra era),
EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum ctx era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum TxOutDatum CtxUTxO era
txoutdata
TxOut StandardBabbage
-> (TxOut StandardBabbage -> TxOut ledgerera) -> TxOut ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe (Script StandardBabbage)
-> Identity (StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage -> Identity (TxOut ledgerera)
(StrictMaybe (Script StandardBabbage)
-> Identity (StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage -> Identity (TxOut StandardBabbage)
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens'
(TxOut StandardBabbage) (StrictMaybe (Script StandardBabbage))
L.referenceScriptTxOutL ((StrictMaybe (Script StandardBabbage)
-> Identity (StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage -> Identity (TxOut ledgerera))
-> StrictMaybe (Script StandardBabbage)
-> TxOut StandardBabbage
-> TxOut ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
refScriptToShelleyScript ShelleyBasedEra era
sbe ReferenceScript era
refScript
AlonzoEraOnwards era
AlonzoEraOnwardsConway ->
Addr (EraCrypto StandardConway)
-> Value StandardConway -> TxOut StandardConway
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value StandardConway
Value (ShelleyLedgerEra era)
value
TxOut StandardConway
-> (TxOut StandardConway -> TxOut StandardConway)
-> TxOut StandardConway
forall a b. a -> (a -> b) -> b
& (Datum StandardConway -> Identity (Datum StandardConway))
-> TxOut StandardConway -> Identity (TxOut StandardConway)
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut StandardConway) (Datum StandardConway)
L.datumTxOutL ((Datum StandardConway -> Identity (Datum StandardConway))
-> TxOut StandardConway -> Identity (TxOut StandardConway))
-> Datum StandardConway
-> TxOut StandardConway
-> TxOut StandardConway
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxOutDatum CtxUTxO era -> Datum (ShelleyLedgerEra era)
forall era.
(Era (ShelleyLedgerEra era),
EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum CtxUTxO era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatumUTxO TxOutDatum CtxUTxO era
txoutdata
TxOut StandardConway
-> (TxOut StandardConway -> TxOut ledgerera) -> TxOut ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe (Script StandardConway)
-> Identity (StrictMaybe (Script StandardConway)))
-> TxOut StandardConway -> Identity (TxOut ledgerera)
(StrictMaybe (Script StandardConway)
-> Identity (StrictMaybe (Script StandardConway)))
-> TxOut StandardConway -> Identity (TxOut StandardConway)
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens' (TxOut StandardConway) (StrictMaybe (Script StandardConway))
L.referenceScriptTxOutL ((StrictMaybe (Script StandardConway)
-> Identity (StrictMaybe (Script StandardConway)))
-> TxOut StandardConway -> Identity (TxOut ledgerera))
-> StrictMaybe (Script StandardConway)
-> TxOut StandardConway
-> TxOut ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
refScriptToShelleyScript ShelleyBasedEra era
sbe ReferenceScript era
refScript
)
ShelleyBasedEra era
sbe
toAlonzoTxOutDatumHashUTxO
:: TxOutDatum CtxUTxO era -> StrictMaybe (Plutus.DataHash StandardCrypto)
toAlonzoTxOutDatumHashUTxO :: forall era.
TxOutDatum CtxUTxO era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
toAlonzoTxOutDatumHashUTxO TxOutDatum CtxUTxO era
TxOutDatumNone = StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. StrictMaybe a
SNothing
toAlonzoTxOutDatumHashUTxO (TxOutDatumHash AlonzoEraOnwards era
_ (ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh)) = SafeHash StandardCrypto EraIndependentData
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. a -> StrictMaybe a
SJust SafeHash StandardCrypto EraIndependentData
dh
toAlonzoTxOutDatumHashUTxO (TxOutDatumInline{}) = StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. StrictMaybe a
SNothing
toBabbageTxOutDatumUTxO
:: (L.Era (ShelleyLedgerEra era), Ledger.EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto)
=> TxOutDatum CtxUTxO era
-> Plutus.Datum (ShelleyLedgerEra era)
toBabbageTxOutDatumUTxO :: forall era.
(Era (ShelleyLedgerEra era),
EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum CtxUTxO era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatumUTxO TxOutDatum CtxUTxO era
TxOutDatumNone = Datum (ShelleyLedgerEra era)
forall era. Datum era
Plutus.NoDatum
toBabbageTxOutDatumUTxO (TxOutDatumHash AlonzoEraOnwards era
_ (ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh)) = DataHash (EraCrypto (ShelleyLedgerEra era))
-> Datum (ShelleyLedgerEra era)
forall era. DataHash (EraCrypto era) -> Datum era
Plutus.DatumHash DataHash (EraCrypto (ShelleyLedgerEra era))
SafeHash StandardCrypto EraIndependentData
dh
toBabbageTxOutDatumUTxO (TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
sd) = HashableScriptData -> Datum (ShelleyLedgerEra era)
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Datum ledgerera
scriptDataToInlineDatum HashableScriptData
sd
fromShelleyTxOut
:: forall era ctx
. ()
=> ShelleyBasedEra era
-> Core.TxOut (ShelleyLedgerEra era)
-> TxOut ctx era
fromShelleyTxOut :: forall era ctx.
ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut ctx era
fromShelleyTxOut ShelleyBasedEra era
sbe TxOut (ShelleyLedgerEra era)
ledgerTxOut = ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxOut ctx era)
-> TxOut ctx era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxOut ctx era)
-> TxOut ctx era)
-> (ShelleyBasedEraConstraints era => TxOut ctx era)
-> TxOut ctx era
forall a b. (a -> b) -> a -> b
$ do
let txOutValue :: TxOutValue era
txOutValue = ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall era.
(Eq (Value (ShelleyLedgerEra era)),
Show (Value (ShelleyLedgerEra era))) =>
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
TxOutValueShelleyBased ShelleyBasedEra era
sbe (Value (ShelleyLedgerEra era) -> TxOutValue era)
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall a b. (a -> b) -> a -> b
$ TxOut (ShelleyLedgerEra era)
ledgerTxOut TxOut (ShelleyLedgerEra era)
-> Getting
(Value (ShelleyLedgerEra era))
(TxOut (ShelleyLedgerEra era))
(Value (ShelleyLedgerEra era))
-> Value (ShelleyLedgerEra era)
forall s a. s -> Getting a s a -> a
^. ShelleyBasedEra era
-> Lens'
(TxOut (ShelleyLedgerEra era)) (Value (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> Lens'
(TxOut (ShelleyLedgerEra era)) (Value (ShelleyLedgerEra era))
A.valueTxOutL ShelleyBasedEra era
sbe
let addressInEra :: AddressInEra era
addressInEra = ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
forall era.
ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
fromShelleyAddr ShelleyBasedEra era
sbe (Addr StandardCrypto -> AddressInEra era)
-> Addr StandardCrypto -> AddressInEra era
forall a b. (a -> b) -> a -> b
$ TxOut (ShelleyLedgerEra era)
ledgerTxOut TxOut (ShelleyLedgerEra era)
-> Getting
(Addr StandardCrypto)
(TxOut (ShelleyLedgerEra era))
(Addr StandardCrypto)
-> Addr StandardCrypto
forall s a. s -> Getting a s a -> a
^. (Addr (EraCrypto (ShelleyLedgerEra era))
-> Const
(Addr StandardCrypto) (Addr (EraCrypto (ShelleyLedgerEra era))))
-> TxOut (ShelleyLedgerEra era)
-> Const (Addr StandardCrypto) (TxOut (ShelleyLedgerEra era))
Getting
(Addr StandardCrypto)
(TxOut (ShelleyLedgerEra era))
(Addr StandardCrypto)
forall era.
EraTxOut era =>
Lens' (TxOut era) (Addr (EraCrypto era))
Lens'
(TxOut (ShelleyLedgerEra era))
(Addr (EraCrypto (ShelleyLedgerEra era)))
L.addrTxOutL
case ShelleyBasedEra era
sbe of
ShelleyBasedEra era
ShelleyBasedEraShelley ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra era
addressInEra TxOutValue era
txOutValue TxOutDatum ctx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraAllegra ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra era
addressInEra TxOutValue era
txOutValue TxOutDatum ctx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraMary ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut AddressInEra era
addressInEra TxOutValue era
txOutValue TxOutDatum ctx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
ShelleyBasedEra era
ShelleyBasedEraAlonzo ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
AddressInEra era
addressInEra
TxOutValue era
txOutValue
(AlonzoEraOnwards era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOutDatum ctx era
forall era ctx.
AlonzoEraOnwards era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOutDatum ctx era
fromAlonzoTxOutDatumHash AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo StrictMaybe (SafeHash StandardCrypto EraIndependentData)
mDatumHash)
ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
where
mDatumHash :: StrictMaybe (SafeHash StandardCrypto EraIndependentData)
mDatumHash = TxOut (ShelleyLedgerEra era)
AlonzoTxOut (AlonzoEra StandardCrypto)
ledgerTxOut AlonzoTxOut (AlonzoEra StandardCrypto)
-> Getting
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(AlonzoTxOut (AlonzoEra StandardCrypto))
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall s a. s -> Getting a s a -> a
^. (StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Const
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))))
-> TxOut (AlonzoEra StandardCrypto)
-> Const
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(TxOut (AlonzoEra StandardCrypto))
Getting
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(AlonzoTxOut (AlonzoEra StandardCrypto))
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
forall era.
AlonzoEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (DataHash (EraCrypto era)))
Lens'
(TxOut (AlonzoEra StandardCrypto))
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto))))
L.dataHashTxOutL
ShelleyBasedEra era
ShelleyBasedEraBabbage ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
AddressInEra era
addressInEra
TxOutValue era
txOutValue
( AlonzoEraOnwards era
-> BabbageEraOnwards era
-> Datum StandardBabbage
-> TxOutDatum ctx era
forall ledgerera era ctx.
(Era ledgerera, EraCrypto ledgerera ~ StandardCrypto) =>
AlonzoEraOnwards era
-> BabbageEraOnwards era -> Datum ledgerera -> TxOutDatum ctx era
fromBabbageTxOutDatum
AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage
BabbageEraOnwards era
BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage
Datum StandardBabbage
datum
)
( case StrictMaybe (Script StandardBabbage)
mRefScript of
StrictMaybe (Script StandardBabbage)
SNothing -> ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
SJust Script StandardBabbage
refScript ->
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ReferenceScript era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ReferenceScript era
fromShelleyScriptToReferenceScript ShelleyBasedEra era
ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage Script StandardBabbage
Script (ShelleyLedgerEra era)
refScript
)
where
datum :: Datum StandardBabbage
datum = TxOut (ShelleyLedgerEra era)
BabbageTxOut StandardBabbage
ledgerTxOut BabbageTxOut StandardBabbage
-> Getting
(Datum StandardBabbage)
(BabbageTxOut StandardBabbage)
(Datum StandardBabbage)
-> Datum StandardBabbage
forall s a. s -> Getting a s a -> a
^. (Datum StandardBabbage
-> Const (Datum StandardBabbage) (Datum StandardBabbage))
-> TxOut StandardBabbage
-> Const (Datum StandardBabbage) (TxOut StandardBabbage)
Getting
(Datum StandardBabbage)
(BabbageTxOut StandardBabbage)
(Datum StandardBabbage)
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut StandardBabbage) (Datum StandardBabbage)
L.datumTxOutL
mRefScript :: StrictMaybe (Script StandardBabbage)
mRefScript = TxOut (ShelleyLedgerEra era)
BabbageTxOut StandardBabbage
ledgerTxOut BabbageTxOut StandardBabbage
-> Getting
(StrictMaybe (Script StandardBabbage))
(BabbageTxOut StandardBabbage)
(StrictMaybe (Script StandardBabbage))
-> StrictMaybe (Script StandardBabbage)
forall s a. s -> Getting a s a -> a
^. (StrictMaybe (Script StandardBabbage)
-> Const
(StrictMaybe (Script StandardBabbage))
(StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage
-> Const
(StrictMaybe (Script StandardBabbage)) (TxOut StandardBabbage)
Getting
(StrictMaybe (Script StandardBabbage))
(BabbageTxOut StandardBabbage)
(StrictMaybe (Script StandardBabbage))
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens'
(TxOut StandardBabbage) (StrictMaybe (Script StandardBabbage))
L.referenceScriptTxOutL
ShelleyBasedEra era
ShelleyBasedEraConway ->
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
AddressInEra era
addressInEra
TxOutValue era
txOutValue
( AlonzoEraOnwards era
-> BabbageEraOnwards era
-> Datum StandardConway
-> TxOutDatum ctx era
forall ledgerera era ctx.
(Era ledgerera, EraCrypto ledgerera ~ StandardCrypto) =>
AlonzoEraOnwards era
-> BabbageEraOnwards era -> Datum ledgerera -> TxOutDatum ctx era
fromBabbageTxOutDatum
AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway
BabbageEraOnwards era
BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway
Datum StandardConway
datum
)
( case StrictMaybe (Script StandardConway)
mRefScript of
StrictMaybe (Script StandardConway)
SNothing -> ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
SJust Script StandardConway
refScript ->
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ReferenceScript era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ReferenceScript era
fromShelleyScriptToReferenceScript ShelleyBasedEra era
ShelleyBasedEra ConwayEra
ShelleyBasedEraConway Script StandardConway
Script (ShelleyLedgerEra era)
refScript
)
where
datum :: Datum StandardConway
datum = TxOut (ShelleyLedgerEra era)
BabbageTxOut StandardConway
ledgerTxOut BabbageTxOut StandardConway
-> Getting
(Datum StandardConway)
(BabbageTxOut StandardConway)
(Datum StandardConway)
-> Datum StandardConway
forall s a. s -> Getting a s a -> a
^. (Datum StandardConway
-> Const (Datum StandardConway) (Datum StandardConway))
-> TxOut StandardConway
-> Const (Datum StandardConway) (TxOut StandardConway)
Getting
(Datum StandardConway)
(BabbageTxOut StandardConway)
(Datum StandardConway)
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut StandardConway) (Datum StandardConway)
L.datumTxOutL
mRefScript :: StrictMaybe (Script StandardConway)
mRefScript = TxOut (ShelleyLedgerEra era)
BabbageTxOut StandardConway
ledgerTxOut BabbageTxOut StandardConway
-> Getting
(StrictMaybe (Script StandardConway))
(BabbageTxOut StandardConway)
(StrictMaybe (Script StandardConway))
-> StrictMaybe (Script StandardConway)
forall s a. s -> Getting a s a -> a
^. (StrictMaybe (Script StandardConway)
-> Const
(StrictMaybe (Script StandardConway))
(StrictMaybe (Script StandardConway)))
-> TxOut StandardConway
-> Const
(StrictMaybe (Script StandardConway)) (TxOut StandardConway)
Getting
(StrictMaybe (Script StandardConway))
(BabbageTxOut StandardConway)
(StrictMaybe (Script StandardConway))
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens' (TxOut StandardConway) (StrictMaybe (Script StandardConway))
L.referenceScriptTxOutL
toAlonzoTxOutDatumHash
:: TxOutDatum ctx era -> StrictMaybe (Plutus.DataHash StandardCrypto)
toAlonzoTxOutDatumHash :: forall ctx era.
TxOutDatum ctx era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
toAlonzoTxOutDatumHash TxOutDatum ctx era
TxOutDatumNone = StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. StrictMaybe a
SNothing
toAlonzoTxOutDatumHash (TxOutDatumHash AlonzoEraOnwards era
_ (ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh)) = SafeHash StandardCrypto EraIndependentData
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. a -> StrictMaybe a
SJust SafeHash StandardCrypto EraIndependentData
dh
toAlonzoTxOutDatumHash (TxOutDatumInline{}) = StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. StrictMaybe a
SNothing
toAlonzoTxOutDatumHash (TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
d) =
let ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh = HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
d
in SafeHash StandardCrypto EraIndependentData
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall a. a -> StrictMaybe a
SJust SafeHash StandardCrypto EraIndependentData
dh
fromAlonzoTxOutDatumHash
:: AlonzoEraOnwards era
-> StrictMaybe (Plutus.DataHash StandardCrypto)
-> TxOutDatum ctx era
fromAlonzoTxOutDatumHash :: forall era ctx.
AlonzoEraOnwards era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOutDatum ctx era
fromAlonzoTxOutDatumHash AlonzoEraOnwards era
_ StrictMaybe (SafeHash StandardCrypto EraIndependentData)
SNothing = TxOutDatum ctx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
fromAlonzoTxOutDatumHash AlonzoEraOnwards era
w (SJust SafeHash StandardCrypto EraIndependentData
hash) = AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
w (Hash ScriptData -> TxOutDatum ctx era)
-> Hash ScriptData -> TxOutDatum ctx era
forall a b. (a -> b) -> a -> b
$ SafeHash StandardCrypto EraIndependentData -> Hash ScriptData
ScriptDataHash SafeHash StandardCrypto EraIndependentData
hash
toBabbageTxOutDatum
:: (L.Era (ShelleyLedgerEra era), Ledger.EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto)
=> TxOutDatum ctx era
-> Plutus.Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum :: forall era ctx.
(Era (ShelleyLedgerEra era),
EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum ctx era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum TxOutDatum ctx era
TxOutDatumNone = Datum (ShelleyLedgerEra era)
forall era. Datum era
Plutus.NoDatum
toBabbageTxOutDatum (TxOutDatumHash AlonzoEraOnwards era
_ (ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh)) = DataHash (EraCrypto (ShelleyLedgerEra era))
-> Datum (ShelleyLedgerEra era)
forall era. DataHash (EraCrypto era) -> Datum era
Plutus.DatumHash DataHash (EraCrypto (ShelleyLedgerEra era))
SafeHash StandardCrypto EraIndependentData
dh
toBabbageTxOutDatum (TxOutDatumInline BabbageEraOnwards era
_ HashableScriptData
sd) = HashableScriptData -> Datum (ShelleyLedgerEra era)
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Datum ledgerera
scriptDataToInlineDatum HashableScriptData
sd
toBabbageTxOutDatum (TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
d) =
let ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh = HashableScriptData -> Hash ScriptData
hashScriptDataBytes HashableScriptData
d
in DataHash (EraCrypto (ShelleyLedgerEra era))
-> Datum (ShelleyLedgerEra era)
forall era. DataHash (EraCrypto era) -> Datum era
Plutus.DatumHash DataHash (EraCrypto (ShelleyLedgerEra era))
SafeHash StandardCrypto EraIndependentData
dh
fromBabbageTxOutDatum
:: (L.Era ledgerera, Ledger.EraCrypto ledgerera ~ StandardCrypto)
=> AlonzoEraOnwards era
-> BabbageEraOnwards era
-> Plutus.Datum ledgerera
-> TxOutDatum ctx era
fromBabbageTxOutDatum :: forall ledgerera era ctx.
(Era ledgerera, EraCrypto ledgerera ~ StandardCrypto) =>
AlonzoEraOnwards era
-> BabbageEraOnwards era -> Datum ledgerera -> TxOutDatum ctx era
fromBabbageTxOutDatum AlonzoEraOnwards era
_ BabbageEraOnwards era
_ Datum ledgerera
Plutus.NoDatum = TxOutDatum ctx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
fromBabbageTxOutDatum AlonzoEraOnwards era
w BabbageEraOnwards era
_ (Plutus.DatumHash DataHash (EraCrypto ledgerera)
dh) =
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
w (Hash ScriptData -> TxOutDatum ctx era)
-> Hash ScriptData -> TxOutDatum ctx era
forall a b. (a -> b) -> a -> b
$ SafeHash StandardCrypto EraIndependentData -> Hash ScriptData
ScriptDataHash DataHash (EraCrypto ledgerera)
SafeHash StandardCrypto EraIndependentData
dh
fromBabbageTxOutDatum AlonzoEraOnwards era
_ BabbageEraOnwards era
w (Plutus.Datum BinaryData ledgerera
binData) =
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards era
w (HashableScriptData -> TxOutDatum ctx era)
-> HashableScriptData -> TxOutDatum ctx era
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards era -> BinaryData ledgerera -> HashableScriptData
forall ledgerera era.
Era ledgerera =>
BabbageEraOnwards era -> BinaryData ledgerera -> HashableScriptData
binaryDataToScriptData BabbageEraOnwards era
w BinaryData ledgerera
binData
data ViewTx
data BuildTx
data BuildTxWith build a where
ViewTx :: BuildTxWith ViewTx a
BuildTxWith :: a -> BuildTxWith BuildTx a
instance Functor (BuildTxWith build) where
fmap :: forall a b. (a -> b) -> BuildTxWith build a -> BuildTxWith build b
fmap a -> b
_ BuildTxWith build a
ViewTx = BuildTxWith build b
BuildTxWith ViewTx b
forall a. BuildTxWith ViewTx a
ViewTx
fmap a -> b
f (BuildTxWith a
x) = b -> BuildTxWith BuildTx b
forall a. a -> BuildTxWith BuildTx a
BuildTxWith (a -> b
f a
x)
instance Applicative (BuildTxWith ViewTx) where
pure :: forall a. a -> BuildTxWith ViewTx a
pure a
_ = BuildTxWith ViewTx a
forall a. BuildTxWith ViewTx a
ViewTx
BuildTxWith ViewTx (a -> b)
_ <*> :: forall a b.
BuildTxWith ViewTx (a -> b)
-> BuildTxWith ViewTx a -> BuildTxWith ViewTx b
<*> BuildTxWith ViewTx a
_ = BuildTxWith ViewTx b
forall a. BuildTxWith ViewTx a
ViewTx
instance Applicative (BuildTxWith BuildTx) where
pure :: forall a. a -> BuildTxWith BuildTx a
pure = a -> BuildTxWith BuildTx a
forall a. a -> BuildTxWith BuildTx a
BuildTxWith
(BuildTxWith a -> b
f) <*> :: forall a b.
BuildTxWith BuildTx (a -> b)
-> BuildTxWith BuildTx a -> BuildTxWith BuildTx b
<*> (BuildTxWith a
a) = b -> BuildTxWith BuildTx b
forall a. a -> BuildTxWith BuildTx a
BuildTxWith (a -> b
f a
a)
buildTxWithToMaybe :: BuildTxWith build a -> Maybe a
buildTxWithToMaybe :: forall build a. BuildTxWith build a -> Maybe a
buildTxWithToMaybe BuildTxWith build a
ViewTx = Maybe a
forall a. Maybe a
Nothing
buildTxWithToMaybe (BuildTxWith a
a) = a -> Maybe a
forall a. a -> Maybe a
Just a
a
deriving instance Eq a => Eq (BuildTxWith build a)
deriving instance Show a => Show (BuildTxWith build a)
type TxIns build era = [(TxIn, BuildTxWith build (Witness WitCtxTxIn era))]
indexTxIns
:: TxIns BuildTx era
-> [(ScriptWitnessIndex, TxIn, Witness WitCtxTxIn era)]
indexTxIns :: forall era.
TxIns BuildTx era
-> [(ScriptWitnessIndex, TxIn, Witness WitCtxTxIn era)]
indexTxIns TxIns BuildTx era
txins =
[ (Word32 -> ScriptWitnessIndex
ScriptWitnessIndexTxIn Word32
ix, TxIn
txIn, Witness WitCtxTxIn era
witness)
| (Word32
ix, (TxIn
txIn, BuildTxWith Witness WitCtxTxIn era
witness)) <- [Word32]
-> TxIns BuildTx era
-> [(Word32, (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)))]
forall a b. [a] -> [b] -> [(a, b)]
zip [Word32
0 ..] (TxIns BuildTx era
-> [(Word32,
(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)))])
-> TxIns BuildTx era
-> [(Word32, (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)))]
forall a b. (a -> b) -> a -> b
$ TxIns BuildTx era -> TxIns BuildTx era
forall v. [(TxIn, v)] -> [(TxIn, v)]
orderTxIns TxIns BuildTx era
txins
]
where
orderTxIns :: [(TxIn, v)] -> [(TxIn, v)]
orderTxIns :: forall v. [(TxIn, v)] -> [(TxIn, v)]
orderTxIns = ((TxIn, v) -> (TxIn, v) -> Ordering) -> [(TxIn, v)] -> [(TxIn, v)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (TxIn -> TxIn -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (TxIn -> TxIn -> Ordering)
-> ((TxIn, v) -> TxIn) -> (TxIn, v) -> (TxIn, v) -> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (TxIn, v) -> TxIn
forall a b. (a, b) -> a
fst)
data TxInsCollateral era where
TxInsCollateralNone
:: TxInsCollateral era
TxInsCollateral
:: AlonzoEraOnwards era
-> [TxIn]
-> TxInsCollateral era
deriving instance Eq (TxInsCollateral era)
deriving instance Show (TxInsCollateral era)
data TxInsReference era where
TxInsReferenceNone :: TxInsReference era
TxInsReference
:: BabbageEraOnwards era
-> [TxIn]
-> TxInsReference era
deriving instance Eq (TxInsReference era)
deriving instance Show (TxInsReference era)
data TxOutValue era where
TxOutValueByron
:: L.Coin
-> TxOutValue era
TxOutValueShelleyBased
:: ( Eq (Ledger.Value (ShelleyLedgerEra era))
, Show (Ledger.Value (ShelleyLedgerEra era))
)
=> ShelleyBasedEra era
-> L.Value (ShelleyLedgerEra era)
-> TxOutValue era
deriving instance Eq (TxOutValue era)
deriving instance Show (TxOutValue era)
instance IsCardanoEra era => ToJSON (TxOutValue era) where
toJSON :: TxOutValue era -> Value
toJSON = \case
TxOutValueByron Coin
ll ->
Coin -> Value
forall a. ToJSON a => a -> Value
toJSON Coin
ll
TxOutValueShelleyBased ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
val ->
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => Value) -> Value
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => Value) -> Value)
-> (ShelleyBasedEraConstraints era => Value) -> Value
forall a b. (a -> b) -> a -> b
$ Value -> Value
forall a. ToJSON a => a -> Value
toJSON (ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
forall era.
ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
fromLedgerValue ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
val)
instance IsShelleyBasedEra era => FromJSON (TxOutValue era) where
parseJSON :: Value -> Parser (TxOutValue era)
parseJSON = String
-> (Object -> Parser (TxOutValue era))
-> Value
-> Parser (TxOutValue era)
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"TxOutValue" ((Object -> Parser (TxOutValue era))
-> Value -> Parser (TxOutValue era))
-> (Object -> Parser (TxOutValue era))
-> Value
-> Parser (TxOutValue era)
forall a b. (a -> b) -> a -> b
$ \Object
o ->
(ShelleyToAllegraEraConstraints era =>
ShelleyToAllegraEra era -> Parser (TxOutValue era))
-> (MaryEraOnwardsConstraints era =>
MaryEraOnwards era -> Parser (TxOutValue era))
-> ShelleyBasedEra era
-> Parser (TxOutValue era)
forall era a.
(ShelleyToAllegraEraConstraints era =>
ShelleyToAllegraEra era -> a)
-> (MaryEraOnwardsConstraints era => MaryEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToAllegraOrMaryEraOnwards
( \ShelleyToAllegraEra era
shelleyToAlleg -> do
Coin
ll <- Object
o Object -> Key -> Parser Coin
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"lovelace"
let sbe :: ShelleyBasedEra era
sbe = ShelleyToAllegraEra era -> ShelleyBasedEra era
forall era. ShelleyToAllegraEra era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert ShelleyToAllegraEra era
shelleyToAlleg
TxOutValue era -> Parser (TxOutValue era)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxOutValue era -> Parser (TxOutValue era))
-> TxOutValue era -> Parser (TxOutValue era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era)
-> (ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall era.
(Eq (Value (ShelleyLedgerEra era)),
Show (Value (ShelleyLedgerEra era))) =>
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
TxOutValueShelleyBased ShelleyBasedEra era
sbe (Value (ShelleyLedgerEra era) -> TxOutValue era)
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era -> Coin -> Value (ShelleyLedgerEra era)
forall era.
ShelleyBasedEra era -> Coin -> Value (ShelleyLedgerEra era)
A.mkAdaValue ShelleyBasedEra era
sbe Coin
ll
)
( \MaryEraOnwards era
w -> do
let l :: [Item Object]
l = Object -> [Item Object]
forall l. IsList l => l -> [Item l]
toList Object
o
sbe :: ShelleyBasedEra era
sbe = MaryEraOnwards era -> ShelleyBasedEra era
forall era. MaryEraOnwards era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert MaryEraOnwards era
w
[Value]
vals <- (Pair -> Parser Value) -> [Pair] -> Parser [Value]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM Pair -> Parser Value
decodeAssetId [Pair]
[Item Object]
l
TxOutValue era -> Parser (TxOutValue era)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxOutValue era -> Parser (TxOutValue era))
-> TxOutValue era -> Parser (TxOutValue era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era)
-> (ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall era.
(Eq (Value (ShelleyLedgerEra era)),
Show (Value (ShelleyLedgerEra era))) =>
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
TxOutValueShelleyBased ShelleyBasedEra era
sbe (Value (ShelleyLedgerEra era) -> TxOutValue era)
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall a b. (a -> b) -> a -> b
$
MaryEraOnwards era -> Value -> Value (ShelleyLedgerEra era)
forall era.
MaryEraOnwards era -> Value -> Value (ShelleyLedgerEra era)
toLedgerValue MaryEraOnwards era
w (Value -> Value (ShelleyLedgerEra era))
-> Value -> Value (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
[Value] -> Value
forall a. Monoid a => [a] -> a
mconcat [Value]
vals
)
(forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra @era)
where
decodeAssetId :: (Aeson.Key, Aeson.Value) -> Aeson.Parser Value
decodeAssetId :: Pair -> Parser Value
decodeAssetId (Key
polid, Aeson.Object Object
assetNameHm) = do
let polId :: PolicyId
polId = String -> PolicyId
forall a. IsString a => String -> a
fromString (String -> PolicyId) -> (Text -> String) -> Text -> PolicyId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
Text.unpack (Text -> PolicyId) -> Text -> PolicyId
forall a b. (a -> b) -> a -> b
$ Key -> Text
Aeson.toText Key
polid
[(AssetName, Quantity)]
aNameQuantity <- Object -> Parser [(AssetName, Quantity)]
decodeAssets Object
assetNameHm
Value -> Parser Value
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Value -> Parser Value)
-> ([(AssetId, Quantity)] -> Value)
-> [(AssetId, Quantity)]
-> Parser Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(AssetId, Quantity)] -> Value
[Item Value] -> Value
forall l. IsList l => [Item l] -> l
fromList ([(AssetId, Quantity)] -> Parser Value)
-> [(AssetId, Quantity)] -> Parser Value
forall a b. (a -> b) -> a -> b
$
((AssetName, Quantity) -> (AssetId, Quantity))
-> [(AssetName, Quantity)] -> [(AssetId, Quantity)]
forall a b. (a -> b) -> [a] -> [b]
map ((AssetName -> AssetId)
-> (AssetName, Quantity) -> (AssetId, Quantity)
forall a b c. (a -> b) -> (a, c) -> (b, c)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first ((AssetName -> AssetId)
-> (AssetName, Quantity) -> (AssetId, Quantity))
-> (AssetName -> AssetId)
-> (AssetName, Quantity)
-> (AssetId, Quantity)
forall a b. (a -> b) -> a -> b
$ PolicyId -> AssetName -> AssetId
AssetId PolicyId
polId) [(AssetName, Quantity)]
aNameQuantity
decodeAssetId (Key
"lovelace", Aeson.Number Scientific
sci) =
case Scientific -> Maybe Word64
forall i. (Integral i, Bounded i) => Scientific -> Maybe i
toBoundedInteger Scientific
sci of
Just (Word64
ll :: Word64) ->
Value -> Parser Value
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Value -> Parser Value) -> Value -> Parser Value
forall a b. (a -> b) -> a -> b
$ [Item Value] -> Value
forall l. IsList l => [Item l] -> l
fromList [(AssetId
AdaAssetId, Integer -> Quantity
Quantity (Integer -> Quantity) -> Integer -> Quantity
forall a b. (a -> b) -> a -> b
$ Word64 -> Integer
forall a. Integral a => a -> Integer
toInteger Word64
ll)]
Maybe Word64
Nothing ->
String -> Parser Value
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Value) -> String -> Parser Value
forall a b. (a -> b) -> a -> b
$ String
"Expected a Bounded number but got: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Scientific -> String
forall a. Show a => a -> String
show Scientific
sci
decodeAssetId Pair
wrong = String -> Parser Value
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Value) -> String -> Parser Value
forall a b. (a -> b) -> a -> b
$ String
"Expected a policy id and a JSON object but got: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Pair -> String
forall a. Show a => a -> String
show Pair
wrong
decodeAssets :: Aeson.Object -> Aeson.Parser [(AssetName, Quantity)]
decodeAssets :: Object -> Parser [(AssetName, Quantity)]
decodeAssets Object
assetNameHm =
let l :: [Item Object]
l = Object -> [Item Object]
forall l. IsList l => l -> [Item l]
toList Object
assetNameHm
in (Pair -> Parser (AssetName, Quantity))
-> [Pair] -> Parser [(AssetName, Quantity)]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
forall (m :: * -> *) a b. Monad m => (a -> m b) -> [a] -> m [b]
mapM (\(Key
aName, Value
q) -> (,) (AssetName -> Quantity -> (AssetName, Quantity))
-> Parser AssetName -> Parser (Quantity -> (AssetName, Quantity))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Key -> Parser AssetName
parseKeyAsAssetName Key
aName Parser (Quantity -> (AssetName, Quantity))
-> Parser Quantity -> Parser (AssetName, Quantity)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Value -> Parser Quantity
decodeQuantity Value
q) [Pair]
[Item Object]
l
parseKeyAsAssetName :: Aeson.Key -> Aeson.Parser AssetName
parseKeyAsAssetName :: Key -> Parser AssetName
parseKeyAsAssetName Key
aName = Parser AssetName -> Text -> Parser AssetName
forall a. Parser a -> Text -> Parser a
runParsecParser Parser AssetName
parseAssetName (Key -> Text
Aeson.toText Key
aName)
decodeQuantity :: Aeson.Value -> Aeson.Parser Quantity
decodeQuantity :: Value -> Parser Quantity
decodeQuantity (Aeson.Number Scientific
sci) =
case Scientific -> Maybe Word64
forall i. (Integral i, Bounded i) => Scientific -> Maybe i
toBoundedInteger Scientific
sci of
Just (Word64
ll :: Word64) -> Quantity -> Parser Quantity
forall a. a -> Parser a
forall (m :: * -> *) a. Monad m => a -> m a
return (Quantity -> Parser Quantity)
-> (Integer -> Quantity) -> Integer -> Parser Quantity
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Integer -> Quantity
Quantity (Integer -> Parser Quantity) -> Integer -> Parser Quantity
forall a b. (a -> b) -> a -> b
$ Word64 -> Integer
forall a. Integral a => a -> Integer
toInteger Word64
ll
Maybe Word64
Nothing -> String -> Parser Quantity
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Quantity) -> String -> Parser Quantity
forall a b. (a -> b) -> a -> b
$ String
"Expected a Bounded number but got: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Scientific -> String
forall a. Show a => a -> String
show Scientific
sci
decodeQuantity Value
wrong = String -> Parser Quantity
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser Quantity) -> String -> Parser Quantity
forall a b. (a -> b) -> a -> b
$ String
"Expected aeson Number but got: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Value -> String
forall a. Show a => a -> String
show Value
wrong
lovelaceToTxOutValue
:: ()
=> ShelleyBasedEra era
-> L.Coin
-> TxOutValue era
lovelaceToTxOutValue :: forall era. ShelleyBasedEra era -> Coin -> TxOutValue era
lovelaceToTxOutValue ShelleyBasedEra era
era Coin
ll =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
era ((ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era)
-> (ShelleyBasedEraConstraints era => TxOutValue era)
-> TxOutValue era
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall era.
(Eq (Value (ShelleyLedgerEra era)),
Show (Value (ShelleyLedgerEra era))) =>
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
TxOutValueShelleyBased ShelleyBasedEra era
era (Value (ShelleyLedgerEra era) -> TxOutValue era)
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era -> Coin -> Value (ShelleyLedgerEra era)
forall era.
ShelleyBasedEra era -> Coin -> Value (ShelleyLedgerEra era)
A.mkAdaValue ShelleyBasedEra era
era Coin
ll
txOutValueToLovelace :: TxOutValue era -> L.Coin
txOutValueToLovelace :: forall era. TxOutValue era -> Coin
txOutValueToLovelace TxOutValue era
tv =
case TxOutValue era
tv of
TxOutValueByron Coin
l -> Coin
l
TxOutValueShelleyBased ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v -> Value (ShelleyLedgerEra era)
v Value (ShelleyLedgerEra era)
-> Getting Coin (Value (ShelleyLedgerEra era)) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. ShelleyBasedEra era -> Lens' (Value (ShelleyLedgerEra era)) Coin
forall era.
ShelleyBasedEra era -> Lens' (Value (ShelleyLedgerEra era)) Coin
A.adaAssetL ShelleyBasedEra era
sbe
txOutValueToValue :: TxOutValue era -> Value
txOutValueToValue :: forall era. TxOutValue era -> Value
txOutValueToValue TxOutValue era
tv =
case TxOutValue era
tv of
TxOutValueByron Coin
l -> Coin -> Value
lovelaceToValue Coin
l
TxOutValueShelleyBased ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v -> ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
forall era.
ShelleyBasedEra era -> Value (ShelleyLedgerEra era) -> Value
fromLedgerValue ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
v
prettyRenderTxOut :: TxOutInAnyEra -> Text
prettyRenderTxOut :: TxOutInAnyEra -> Text
prettyRenderTxOut (TxOutInAnyEra CardanoEra era
_ (TxOut (AddressInEra AddressTypeInEra addrtype era
_ Address addrtype
addr) TxOutValue era
txOutVal TxOutDatum CtxTx era
_ ReferenceScript era
_)) =
AddressAny -> Text
forall addr. SerialiseAddress addr => addr -> Text
serialiseAddress (Address addrtype -> AddressAny
forall addr. Address addr -> AddressAny
toAddressAny Address addrtype
addr)
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
" + "
Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Value -> Text
renderValue (TxOutValue era -> Value
forall era. TxOutValue era -> Value
txOutValueToValue TxOutValue era
txOutVal)
data TxReturnCollateral ctx era where
TxReturnCollateralNone
:: TxReturnCollateral ctx era
TxReturnCollateral
:: BabbageEraOnwards era
-> TxOut ctx era
-> TxReturnCollateral ctx era
deriving instance Eq (TxReturnCollateral ctx era)
deriving instance Show (TxReturnCollateral ctx era)
data TxTotalCollateral era where
TxTotalCollateralNone
:: TxTotalCollateral era
TxTotalCollateral
:: BabbageEraOnwards era
-> L.Coin
-> TxTotalCollateral era
deriving instance Eq (TxTotalCollateral era)
deriving instance Show (TxTotalCollateral era)
data TxOutDatum ctx era where
TxOutDatumNone :: TxOutDatum ctx era
TxOutDatumHash
:: AlonzoEraOnwards era
-> Hash ScriptData
-> TxOutDatum ctx era
TxOutSupplementalDatum
:: AlonzoEraOnwards era
-> HashableScriptData
-> TxOutDatum CtxTx era
TxOutDatumInline
:: BabbageEraOnwards era
-> HashableScriptData
-> TxOutDatum ctx era
deriving instance Eq (TxOutDatum ctx era)
deriving instance Show (TxOutDatum ctx era)
{-# COMPLETE TxOutDatumNone, TxOutDatumHash, TxOutSupplementalDatum, TxOutDatumInline #-}
parseHash :: SerialiseAsRawBytes (Hash a) => AsType (Hash a) -> Parsec.Parser (Hash a)
parseHash :: forall a.
SerialiseAsRawBytes (Hash a) =>
AsType (Hash a) -> Parser (Hash a)
parseHash AsType (Hash a)
asType = do
String
str <- ParsecT String () Identity Char
-> ParsecT String () Identity String
forall a.
ParsecT String () Identity a -> ParsecT String () Identity [a]
forall (f :: * -> *) a. Alternative f => f a -> f [a]
some ParsecT String () Identity Char
forall s (m :: * -> *) u. Stream s m Char => ParsecT s u m Char
Parsec.hexDigit ParsecT String () Identity String
-> String -> ParsecT String () Identity String
forall s u (m :: * -> *) a.
ParsecT s u m a -> String -> ParsecT s u m a
<?> String
"hash"
(RawBytesHexError -> String)
-> Either RawBytesHexError (Hash a) -> Parser (Hash a)
forall (m :: * -> *) e a.
MonadFail m =>
(e -> String) -> Either e a -> m a
failEitherWith (\RawBytesHexError
e -> String
"Failed to parse hash: " String -> ShowS
forall a. [a] -> [a] -> [a]
++ RawBytesHexError -> String
forall a. Error a => a -> String
displayError RawBytesHexError
e) (Either RawBytesHexError (Hash a) -> Parser (Hash a))
-> Either RawBytesHexError (Hash a) -> Parser (Hash a)
forall a b. (a -> b) -> a -> b
$
AsType (Hash a) -> ByteString -> Either RawBytesHexError (Hash a)
forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Either RawBytesHexError a
deserialiseFromRawBytesHex AsType (Hash a)
asType (String -> ByteString
BSC.pack String
str)
data TxFee era where
TxFeeExplicit :: ShelleyBasedEra era -> L.Coin -> TxFee era
deriving instance Eq (TxFee era)
deriving instance Show (TxFee era)
defaultTxFee :: ShelleyBasedEra era -> TxFee era
defaultTxFee :: forall era. ShelleyBasedEra era -> TxFee era
defaultTxFee ShelleyBasedEra era
w = ShelleyBasedEra era -> Coin -> TxFee era
forall era. ShelleyBasedEra era -> Coin -> TxFee era
TxFeeExplicit ShelleyBasedEra era
w Coin
forall a. Monoid a => a
mempty
data TxValidityUpperBound era where
TxValidityUpperBound
:: ShelleyBasedEra era
-> Maybe SlotNo
-> TxValidityUpperBound era
deriving instance Eq (TxValidityUpperBound era)
deriving instance Show (TxValidityUpperBound era)
defaultTxValidityUpperBound
:: ()
=> ShelleyBasedEra era
-> TxValidityUpperBound era
defaultTxValidityUpperBound :: forall era. ShelleyBasedEra era -> TxValidityUpperBound era
defaultTxValidityUpperBound ShelleyBasedEra era
sbe = ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
forall era.
ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
TxValidityUpperBound ShelleyBasedEra era
sbe Maybe SlotNo
forall a. Maybe a
Nothing
data TxValidityLowerBound era where
TxValidityNoLowerBound
:: TxValidityLowerBound era
TxValidityLowerBound
:: AllegraEraOnwards era
-> SlotNo
-> TxValidityLowerBound era
deriving instance Eq (TxValidityLowerBound era)
deriving instance Show (TxValidityLowerBound era)
data TxMetadataInEra era where
TxMetadataNone
:: TxMetadataInEra era
TxMetadataInEra
:: ShelleyBasedEra era
-> TxMetadata
-> TxMetadataInEra era
deriving instance Eq (TxMetadataInEra era)
deriving instance Show (TxMetadataInEra era)
data TxAuxScripts era where
TxAuxScriptsNone
:: TxAuxScripts era
TxAuxScripts
:: AllegraEraOnwards era
-> [ScriptInEra era]
-> TxAuxScripts era
deriving instance Eq (TxAuxScripts era)
deriving instance Show (TxAuxScripts era)
data era where
:: TxExtraKeyWitnesses era
:: AlonzoEraOnwards era
-> [Hash PaymentKey]
-> TxExtraKeyWitnesses era
deriving instance Eq (TxExtraKeyWitnesses era)
deriving instance Show (TxExtraKeyWitnesses era)
data TxWithdrawals build era where
TxWithdrawalsNone
:: TxWithdrawals build era
TxWithdrawals
:: ShelleyBasedEra era
-> [(StakeAddress, L.Coin, BuildTxWith build (Witness WitCtxStake era))]
-> TxWithdrawals build era
deriving instance Eq (TxWithdrawals build era)
deriving instance Show (TxWithdrawals build era)
indexTxWithdrawals
:: TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, StakeAddress, L.Coin, Witness WitCtxStake era)]
indexTxWithdrawals :: forall era.
TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, StakeAddress, Coin,
Witness WitCtxStake era)]
indexTxWithdrawals TxWithdrawals BuildTx era
TxWithdrawalsNone = []
indexTxWithdrawals (TxWithdrawals ShelleyBasedEra era
_ [(StakeAddress, Coin,
BuildTxWith BuildTx (Witness WitCtxStake era))]
withdrawals) =
[ (Word32 -> ScriptWitnessIndex
ScriptWitnessIndexWithdrawal Word32
ix, StakeAddress
addr, Coin
coin, Witness WitCtxStake era
witness)
| (Word32
ix, (StakeAddress
addr, Coin
coin, BuildTxWith Witness WitCtxStake era
witness)) <- [Word32]
-> [(StakeAddress, Coin,
BuildTxWith BuildTx (Witness WitCtxStake era))]
-> [(Word32,
(StakeAddress, Coin,
BuildTxWith BuildTx (Witness WitCtxStake era)))]
forall a b. [a] -> [b] -> [(a, b)]
zip [Word32
0 ..] ([(StakeAddress, Coin,
BuildTxWith BuildTx (Witness WitCtxStake era))]
-> [(StakeAddress, Coin,
BuildTxWith BuildTx (Witness WitCtxStake era))]
forall x v. [(StakeAddress, x, v)] -> [(StakeAddress, x, v)]
orderStakeAddrs [(StakeAddress, Coin,
BuildTxWith BuildTx (Witness WitCtxStake era))]
withdrawals)
]
where
orderStakeAddrs :: [(StakeAddress, x, v)] -> [(StakeAddress, x, v)]
orderStakeAddrs :: forall x v. [(StakeAddress, x, v)] -> [(StakeAddress, x, v)]
orderStakeAddrs = ((StakeAddress, x, v) -> (StakeAddress, x, v) -> Ordering)
-> [(StakeAddress, x, v)] -> [(StakeAddress, x, v)]
forall a. (a -> a -> Ordering) -> [a] -> [a]
sortBy (StakeAddress -> StakeAddress -> Ordering
forall a. Ord a => a -> a -> Ordering
compare (StakeAddress -> StakeAddress -> Ordering)
-> ((StakeAddress, x, v) -> StakeAddress)
-> (StakeAddress, x, v)
-> (StakeAddress, x, v)
-> Ordering
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` (\(StakeAddress
k, x
_, v
_) -> StakeAddress
k))
data TxCertificates build era where
TxCertificatesNone
:: TxCertificates build era
TxCertificates
:: ShelleyBasedEra era
-> [Certificate era]
-> BuildTxWith build [(StakeCredential, Witness WitCtxStake era)]
-> TxCertificates build era
deriving instance Eq (TxCertificates build era)
deriving instance Show (TxCertificates build era)
indexTxCertificates
:: TxCertificates BuildTx era
-> [(ScriptWitnessIndex, Certificate era, StakeCredential, Witness WitCtxStake era)]
indexTxCertificates :: forall era.
TxCertificates BuildTx era
-> [(ScriptWitnessIndex, Certificate era, StakeCredential,
Witness WitCtxStake era)]
indexTxCertificates TxCertificates BuildTx era
TxCertificatesNone = []
indexTxCertificates (TxCertificates ShelleyBasedEra era
_ [Certificate era]
certs (BuildTxWith [(StakeCredential, Witness WitCtxStake era)]
witnesses)) =
[ (Word32 -> ScriptWitnessIndex
ScriptWitnessIndexCertificate Word32
ix, Certificate era
cert, StakeCredential
stakeCred, Witness WitCtxStake era
wit)
| (Word32
ix, Certificate era
cert) <- [Word32] -> [Certificate era] -> [(Word32, Certificate era)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Word32
0 ..] [Certificate era]
certs
, StakeCredential
stakeCred <- Maybe StakeCredential -> [StakeCredential]
forall a. Maybe a -> [a]
maybeToList (Certificate era -> Maybe StakeCredential
forall era. Certificate era -> Maybe StakeCredential
selectStakeCredentialWitness Certificate era
cert)
, Witness WitCtxStake era
wit <- StakeCredential
-> [(StakeCredential, Witness WitCtxStake era)]
-> [Witness WitCtxStake era]
forall {b} {b}. Eq b => b -> [(b, b)] -> [b]
findAll StakeCredential
stakeCred [(StakeCredential, Witness WitCtxStake era)]
witnesses
]
where
findAll :: b -> [(b, b)] -> [b]
findAll b
needle = ((b, b) -> b) -> [(b, b)] -> [b]
forall a b. (a -> b) -> [a] -> [b]
map (b, b) -> b
forall a b. (a, b) -> b
snd ([(b, b)] -> [b]) -> ([(b, b)] -> [(b, b)]) -> [(b, b)] -> [b]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((b, b) -> Bool) -> [(b, b)] -> [(b, b)]
forall a. (a -> Bool) -> [a] -> [a]
filter (b -> b -> Bool
forall a. Eq a => a -> a -> Bool
(==) b
needle (b -> Bool) -> ((b, b) -> b) -> (b, b) -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (b, b) -> b
forall a b. (a, b) -> a
fst)
data TxUpdateProposal era where
TxUpdateProposalNone :: TxUpdateProposal era
TxUpdateProposal :: ShelleyToBabbageEra era -> UpdateProposal -> TxUpdateProposal era
deriving instance Eq (TxUpdateProposal era)
deriving instance Show (TxUpdateProposal era)
data TxMintValue build era where
TxMintNone :: TxMintValue build era
TxMintValue
:: MaryEraOnwards era
-> Map
PolicyId
[ ( AssetName
, Quantity
, BuildTxWith build (ScriptWitness WitCtxMint era)
)
]
-> TxMintValue build era
deriving instance Eq (TxMintValue build era)
deriving instance Show (TxMintValue build era)
txMintValueToValue :: TxMintValue build era -> Value
txMintValueToValue :: forall build era. TxMintValue build era -> Value
txMintValueToValue TxMintValue build era
TxMintNone = Value
forall a. Monoid a => a
mempty
txMintValueToValue (TxMintValue MaryEraOnwards era
_ Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
policiesWithAssets) =
[Item Value] -> Value
forall l. IsList l => [Item l] -> l
fromList
[ (PolicyId -> AssetName -> AssetId
AssetId PolicyId
policyId' AssetName
assetName', Quantity
quantity)
| (PolicyId
policyId', [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets) <- Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> [Item
(Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))])]
forall l. IsList l => l -> [Item l]
toList Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
policiesWithAssets
, (AssetName
assetName', Quantity
quantity, BuildTxWith build (ScriptWitness WitCtxMint era)
_) <- [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets
]
indexTxMintValue
:: TxMintValue build era
-> [ ( ScriptWitnessIndex
, PolicyId
, AssetName
, Quantity
, BuildTxWith build (ScriptWitness WitCtxMint era)
)
]
indexTxMintValue :: forall build era.
TxMintValue build era
-> [(ScriptWitnessIndex, PolicyId, AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
indexTxMintValue TxMintValue build era
TxMintNone = []
indexTxMintValue (TxMintValue MaryEraOnwards era
_ Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
policiesWithAssets) =
[ (Word32 -> ScriptWitnessIndex
ScriptWitnessIndexMint Word32
ix, PolicyId
policyId', AssetName
assetName', Quantity
quantity, BuildTxWith build (ScriptWitness WitCtxMint era)
witness)
| (Word32
ix, (PolicyId
policyId', [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets)) <- [Word32]
-> [(PolicyId,
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))])]
-> [(Word32,
(PolicyId,
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]))]
forall a b. [a] -> [b] -> [(a, b)]
zip [Word32
0 ..] ([(PolicyId,
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))])]
-> [(Word32,
(PolicyId,
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]))])
-> [(PolicyId,
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))])]
-> [(Word32,
(PolicyId,
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]))]
forall a b. (a -> b) -> a -> b
$ Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> [Item
(Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))])]
forall l. IsList l => l -> [Item l]
toList Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
policiesWithAssets
, (AssetName
assetName', Quantity
quantity, BuildTxWith build (ScriptWitness WitCtxMint era)
witness) <- [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets
]
data TxVotingProcedures build era where
TxVotingProceduresNone :: TxVotingProcedures build era
TxVotingProcedures
:: L.VotingProcedures (ShelleyLedgerEra era)
-> BuildTxWith
build
(Map (Ledger.Voter (Ledger.EraCrypto (ShelleyLedgerEra era))) (ScriptWitness WitCtxStake era))
-> TxVotingProcedures build era
deriving instance Eq (TxVotingProcedures build era)
deriving instance Show (TxVotingProcedures build era)
mkTxVotingProcedures
:: Applicative (BuildTxWith build)
=> [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> Either (VotesMergingConflict era) (TxVotingProcedures build era)
mkTxVotingProcedures :: forall build era.
Applicative (BuildTxWith build) =>
[(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> Either (VotesMergingConflict era) (TxVotingProcedures build era)
mkTxVotingProcedures [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
votingProcedures = do
VotingProcedures VotingProcedures (ShelleyLedgerEra era)
procedure <-
(VotingProcedures era
-> (VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))
-> Either (VotesMergingConflict era) (VotingProcedures era))
-> VotingProcedures era
-> [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> Either (VotesMergingConflict era) (VotingProcedures era)
forall (t :: * -> *) (m :: * -> *) b a.
(Foldable t, Monad m) =>
(b -> a -> m b) -> b -> t a -> m b
foldM VotingProcedures era
-> (VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))
-> Either (VotesMergingConflict era) (VotingProcedures era)
forall {era} {b}.
VotingProcedures era
-> (VotingProcedures era, b)
-> Either (VotesMergingConflict era) (VotingProcedures era)
f VotingProcedures era
forall era. VotingProcedures era
emptyVotingProcedures [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
votingProcedures
TxVotingProcedures build era
-> Either (VotesMergingConflict era) (TxVotingProcedures build era)
forall a. a -> Either (VotesMergingConflict era) a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxVotingProcedures build era
-> Either
(VotesMergingConflict era) (TxVotingProcedures build era))
-> TxVotingProcedures build era
-> Either (VotesMergingConflict era) (TxVotingProcedures build era)
forall a b. (a -> b) -> a -> b
$ VotingProcedures (ShelleyLedgerEra era)
-> BuildTxWith
build
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
-> TxVotingProcedures build era
forall era build.
VotingProcedures (ShelleyLedgerEra era)
-> BuildTxWith
build
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
-> TxVotingProcedures build era
TxVotingProcedures VotingProcedures (ShelleyLedgerEra era)
procedure (Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
-> BuildTxWith
build
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
forall a. a -> BuildTxWith build a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
votingScriptWitnessMap)
where
votingScriptWitnessMap :: Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
votingScriptWitnessMap =
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
-> (VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
-> [(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
foldl
(\Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
acc (VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))
next -> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
acc Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall k a. Ord k => Map k a -> Map k a -> Map k a
`Map.union` (VotingProcedures era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
-> (VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry VotingProcedures era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall era.
VotingProcedures era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
votingScriptWitnessSingleton (VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))
next)
Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall k a. Map k a
Map.empty
[(VotingProcedures era, Maybe (ScriptWitness WitCtxStake era))]
votingProcedures
f :: VotingProcedures era
-> (VotingProcedures era, b)
-> Either (VotesMergingConflict era) (VotingProcedures era)
f VotingProcedures era
acc (VotingProcedures era
procedure, b
_witness) = VotingProcedures era
-> VotingProcedures era
-> Either (VotesMergingConflict era) (VotingProcedures era)
forall era.
VotingProcedures era
-> VotingProcedures era
-> Either (VotesMergingConflict era) (VotingProcedures era)
mergeVotingProcedures VotingProcedures era
acc VotingProcedures era
procedure
votingScriptWitnessSingleton
:: VotingProcedures era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map (L.Voter (L.EraCrypto (ShelleyLedgerEra era))) (ScriptWitness WitCtxStake era)
votingScriptWitnessSingleton :: forall era.
VotingProcedures era
-> Maybe (ScriptWitness WitCtxStake era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
votingScriptWitnessSingleton VotingProcedures era
_ Maybe (ScriptWitness WitCtxStake era)
Nothing = Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall k a. Map k a
Map.empty
votingScriptWitnessSingleton VotingProcedures era
votingProcedures' (Just ScriptWitness WitCtxStake era
scriptWitness) = do
let voter :: Voter (EraCrypto (ShelleyLedgerEra era))
voter = Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
-> Voter (EraCrypto (ShelleyLedgerEra era))
forall a. HasCallStack => Maybe a -> a
fromJust (Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
-> Voter (EraCrypto (ShelleyLedgerEra era)))
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
-> Voter (EraCrypto (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ VotingProcedures era
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
forall era.
VotingProcedures era
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
getVotingScriptCredentials VotingProcedures era
votingProcedures'
Voter (EraCrypto (ShelleyLedgerEra era))
-> ScriptWitness WitCtxStake era
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
forall k a. k -> a -> Map k a
Map.singleton Voter (EraCrypto (ShelleyLedgerEra era))
voter ScriptWitness WitCtxStake era
scriptWitness
getVotingScriptCredentials
:: VotingProcedures era
-> Maybe (L.Voter (L.EraCrypto (ShelleyLedgerEra era)))
getVotingScriptCredentials :: forall era.
VotingProcedures era
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
getVotingScriptCredentials (VotingProcedures (L.VotingProcedures Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
m)) =
[Voter (EraCrypto (ShelleyLedgerEra era))]
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
forall a. [a] -> Maybe a
listToMaybe ([Voter (EraCrypto (ShelleyLedgerEra era))]
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era))))
-> [Voter (EraCrypto (ShelleyLedgerEra era))]
-> Maybe (Voter (EraCrypto (ShelleyLedgerEra era)))
forall a b. (a -> b) -> a -> b
$ Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
-> [Voter (EraCrypto (ShelleyLedgerEra era))]
forall k a. Map k a -> [k]
Map.keys Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
m
indexTxVotingProcedures
:: TxVotingProcedures BuildTx era
-> [ ( ScriptWitnessIndex
, L.Voter (Ledger.EraCrypto (ShelleyLedgerEra era))
, ScriptWitness WitCtxStake era
)
]
indexTxVotingProcedures :: forall era.
TxVotingProcedures BuildTx era
-> [(ScriptWitnessIndex, Voter (EraCrypto (ShelleyLedgerEra era)),
ScriptWitness WitCtxStake era)]
indexTxVotingProcedures TxVotingProcedures BuildTx era
TxVotingProceduresNone = []
indexTxVotingProcedures (TxVotingProcedures VotingProcedures (ShelleyLedgerEra era)
vProcedures (BuildTxWith Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
sWitMap)) =
[ (Word32 -> ScriptWitnessIndex
ScriptWitnessIndexVoting (Word32 -> ScriptWitnessIndex) -> Word32 -> ScriptWitnessIndex
forall a b. (a -> b) -> a -> b
$ Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
index, Voter (EraCrypto (ShelleyLedgerEra era))
vote, ScriptWitness WitCtxStake era
scriptWitness)
| let allVoteMap :: Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
allVoteMap = VotingProcedures (ShelleyLedgerEra era)
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
forall era.
VotingProcedures era
-> Map
(Voter (EraCrypto era))
(Map (GovActionId (EraCrypto era)) (VotingProcedure era))
L.unVotingProcedures VotingProcedures (ShelleyLedgerEra era)
vProcedures
, (Voter (EraCrypto (ShelleyLedgerEra era))
vote, ScriptWitness WitCtxStake era
scriptWitness) <- Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
-> [Item
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))]
forall l. IsList l => l -> [Item l]
toList Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era)
sWitMap
, Int
index <- Maybe Int -> [Int]
forall a. Maybe a -> [a]
maybeToList (Maybe Int -> [Int]) -> Maybe Int -> [Int]
forall a b. (a -> b) -> a -> b
$ Voter (EraCrypto (ShelleyLedgerEra era))
-> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
-> Maybe Int
forall k a. Ord k => k -> Map k a -> Maybe Int
Map.lookupIndex Voter (EraCrypto (ShelleyLedgerEra era))
vote Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
allVoteMap
]
data TxProposalProcedures build era where
TxProposalProceduresNone :: TxProposalProcedures build era
TxProposalProcedures
:: Ledger.EraPParams (ShelleyLedgerEra era)
=> OSet (L.ProposalProcedure (ShelleyLedgerEra era))
-> BuildTxWith build (Map (L.ProposalProcedure (ShelleyLedgerEra era)) (ScriptWitness WitCtxStake era))
-> TxProposalProcedures build era
deriving instance Eq (TxProposalProcedures build era)
deriving instance Show (TxProposalProcedures build era)
mkTxProposalProcedures
:: forall era build
. Applicative (BuildTxWith build)
=> IsShelleyBasedEra era
=> [(L.ProposalProcedure (ShelleyLedgerEra era), Maybe (ScriptWitness WitCtxStake era))]
-> TxProposalProcedures build era
mkTxProposalProcedures :: forall era build.
(Applicative (BuildTxWith build), IsShelleyBasedEra era) =>
[(ProposalProcedure (ShelleyLedgerEra era),
Maybe (ScriptWitness WitCtxStake era))]
-> TxProposalProcedures build era
mkTxProposalProcedures [(ProposalProcedure (ShelleyLedgerEra era),
Maybe (ScriptWitness WitCtxStake era))]
proposalsWithWitnessesList = do
let ([ProposalProcedure (ShelleyLedgerEra era)]
proposals, [(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]
proposalsWithWitnesses) =
(DList (ProposalProcedure (ShelleyLedgerEra era))
-> [ProposalProcedure (ShelleyLedgerEra era)])
-> (DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)
-> [(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)])
-> (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
-> ([ProposalProcedure (ShelleyLedgerEra era)],
[(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)])
forall a b c d. (a -> b) -> (c -> d) -> (a, c) -> (b, d)
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap DList (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (DList (ProposalProcedure (ShelleyLedgerEra era)))]
DList (ProposalProcedure (ShelleyLedgerEra era))
-> [ProposalProcedure (ShelleyLedgerEra era)]
forall l. IsList l => l -> [Item l]
toList DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)
-> [(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)
-> [Item
(DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))]
forall l. IsList l => l -> [Item l]
toList ((DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
-> ([ProposalProcedure (ShelleyLedgerEra era)],
[(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]))
-> (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
-> ([ProposalProcedure (ShelleyLedgerEra era)],
[(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)])
forall a b. (a -> b) -> a -> b
$
((DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
-> (ProposalProcedure (ShelleyLedgerEra era),
Maybe (ScriptWitness WitCtxStake era))
-> (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)))
-> (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
-> [(ProposalProcedure (ShelleyLedgerEra era),
Maybe (ScriptWitness WitCtxStake era))]
-> (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
forall b a. (b -> a -> b) -> b -> [a] -> b
forall (t :: * -> *) b a.
Foldable t =>
(b -> a -> b) -> b -> t a -> b
Foldable.foldl' (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
-> (ProposalProcedure (ShelleyLedgerEra era),
Maybe (ScriptWitness WitCtxStake era))
-> (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
forall {a} {b}.
(DList a, DList (a, b)) -> (a, Maybe b) -> (DList a, DList (a, b))
partitionProposals (DList (ProposalProcedure (ShelleyLedgerEra era)),
DList
(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era))
forall a. Monoid a => a
mempty [(ProposalProcedure (ShelleyLedgerEra era),
Maybe (ScriptWitness WitCtxStake era))]
proposalsWithWitnessesList
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
TxProposalProcedures build era)
-> TxProposalProcedures build era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints (forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra @era) ((ShelleyBasedEraConstraints era => TxProposalProcedures build era)
-> TxProposalProcedures build era)
-> (ShelleyBasedEraConstraints era =>
TxProposalProcedures build era)
-> TxProposalProcedures build era
forall a b. (a -> b) -> a -> b
$
OSet (ProposalProcedure (ShelleyLedgerEra era))
-> BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> TxProposalProcedures build era
forall era build.
EraPParams (ShelleyLedgerEra era) =>
OSet (ProposalProcedure (ShelleyLedgerEra era))
-> BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> TxProposalProcedures build era
TxProposalProcedures ([Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall l. IsList l => [Item l] -> l
fromList [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
[ProposalProcedure (ShelleyLedgerEra era)]
proposals) (Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
-> BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
forall a. a -> BuildTxWith build a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
-> BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)))
-> Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
-> BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
forall a b. (a -> b) -> a -> b
$ [Item
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))]
-> Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
forall l. IsList l => [Item l] -> l
fromList [(ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]
[Item
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))]
proposalsWithWitnesses)
where
partitionProposals :: (DList a, DList (a, b)) -> (a, Maybe b) -> (DList a, DList (a, b))
partitionProposals (DList a
ps, DList (a, b)
pws) (a
p, Maybe b
Nothing) =
(DList a -> a -> DList a
forall a. DList a -> a -> DList a
DList.snoc DList a
ps a
p, DList (a, b)
pws)
partitionProposals (DList a
ps, DList (a, b)
pws) (a
p, Just b
w) =
(DList a -> a -> DList a
forall a. DList a -> a -> DList a
DList.snoc DList a
ps a
p, DList (a, b) -> (a, b) -> DList (a, b)
forall a. DList a -> a -> DList a
DList.snoc DList (a, b)
pws (a
p, b
w))
indexTxProposalProcedures
:: TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, L.ProposalProcedure (ShelleyLedgerEra era), ScriptWitness WitCtxStake era)]
indexTxProposalProcedures :: forall era.
TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]
indexTxProposalProcedures TxProposalProcedures BuildTx era
TxProposalProceduresNone = []
indexTxProposalProcedures txpp :: TxProposalProcedures BuildTx era
txpp@(TxProposalProcedures OSet (ProposalProcedure (ShelleyLedgerEra era))
_ (BuildTxWith Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
witnesses)) = do
let allProposalsList :: [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
allProposalsList = OSet (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
forall l. IsList l => l -> [Item l]
toList (OSet (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))])
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
-> [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
forall a b. (a -> b) -> a -> b
$ TxProposalProcedures BuildTx era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall build era.
TxProposalProcedures build era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures TxProposalProcedures BuildTx era
txpp
[ (Word32 -> ScriptWitnessIndex
ScriptWitnessIndexProposing (Word32 -> ScriptWitnessIndex) -> Word32 -> ScriptWitnessIndex
forall a b. (a -> b) -> a -> b
$ Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ix, ProposalProcedure (ShelleyLedgerEra era)
proposal, ScriptWitness WitCtxStake era
scriptWitness)
| (ProposalProcedure (ShelleyLedgerEra era)
proposal, ScriptWitness WitCtxStake era
scriptWitness) <- Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
-> [Item
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))]
forall l. IsList l => l -> [Item l]
toList Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
witnesses
, Int
ix <- Maybe Int -> [Int]
forall a. Maybe a -> [a]
maybeToList (Maybe Int -> [Int]) -> Maybe Int -> [Int]
forall a b. (a -> b) -> a -> b
$ ProposalProcedure (ShelleyLedgerEra era)
-> [ProposalProcedure (ShelleyLedgerEra era)] -> Maybe Int
forall a. Eq a => a -> [a] -> Maybe Int
List.elemIndex ProposalProcedure (ShelleyLedgerEra era)
proposal [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
[ProposalProcedure (ShelleyLedgerEra era)]
allProposalsList
]
data TxBodyContent build era
= TxBodyContent
{ forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns build era
, forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral :: TxInsCollateral era
, forall build era. TxBodyContent build era -> TxInsReference era
txInsReference :: TxInsReference era
, forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
, forall build era. TxBodyContent build era -> TxTotalCollateral era
txTotalCollateral :: TxTotalCollateral era
, forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txReturnCollateral :: TxReturnCollateral CtxTx era
, forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
, forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound :: TxValidityLowerBound era
, forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
, forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
, forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts era
, :: TxExtraKeyWitnesses era
, forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
txProtocolParams :: BuildTxWith build (Maybe (LedgerProtocolParameters era))
, forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals build era
, forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates build era
, forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
, forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue build era
, forall build era. TxBodyContent build era -> TxScriptValidity era
txScriptValidity :: TxScriptValidity era
, forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures build era))
txProposalProcedures :: Maybe (Featured ConwayEraOnwards era (TxProposalProcedures build era))
, forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures build era))
txVotingProcedures :: Maybe (Featured ConwayEraOnwards era (TxVotingProcedures build era))
, forall build era.
TxBodyContent build era
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue :: Maybe (Featured ConwayEraOnwards era (Maybe L.Coin))
, forall build era.
TxBodyContent build era
-> Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation :: Maybe (Featured ConwayEraOnwards era L.Coin)
}
deriving (TxBodyContent build era -> TxBodyContent build era -> Bool
(TxBodyContent build era -> TxBodyContent build era -> Bool)
-> (TxBodyContent build era -> TxBodyContent build era -> Bool)
-> Eq (TxBodyContent build era)
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
forall build era.
IsShelleyBasedEra era =>
TxBodyContent build era -> TxBodyContent build era -> Bool
$c== :: forall build era.
IsShelleyBasedEra era =>
TxBodyContent build era -> TxBodyContent build era -> Bool
== :: TxBodyContent build era -> TxBodyContent build era -> Bool
$c/= :: forall build era.
IsShelleyBasedEra era =>
TxBodyContent build era -> TxBodyContent build era -> Bool
/= :: TxBodyContent build era -> TxBodyContent build era -> Bool
Eq, Int -> TxBodyContent build era -> ShowS
[TxBodyContent build era] -> ShowS
TxBodyContent build era -> String
(Int -> TxBodyContent build era -> ShowS)
-> (TxBodyContent build era -> String)
-> ([TxBodyContent build era] -> ShowS)
-> Show (TxBodyContent build era)
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
forall build era.
IsShelleyBasedEra era =>
Int -> TxBodyContent build era -> ShowS
forall build era.
IsShelleyBasedEra era =>
[TxBodyContent build era] -> ShowS
forall build era.
IsShelleyBasedEra era =>
TxBodyContent build era -> String
$cshowsPrec :: forall build era.
IsShelleyBasedEra era =>
Int -> TxBodyContent build era -> ShowS
showsPrec :: Int -> TxBodyContent build era -> ShowS
$cshow :: forall build era.
IsShelleyBasedEra era =>
TxBodyContent build era -> String
show :: TxBodyContent build era -> String
$cshowList :: forall build era.
IsShelleyBasedEra era =>
[TxBodyContent build era] -> ShowS
showList :: [TxBodyContent build era] -> ShowS
Show)
defaultTxBodyContent
:: ()
=> ShelleyBasedEra era
-> TxBodyContent BuildTx era
defaultTxBodyContent :: forall era. ShelleyBasedEra era -> TxBodyContent BuildTx era
defaultTxBodyContent ShelleyBasedEra era
era =
TxBodyContent
{ txIns :: TxIns BuildTx era
txIns = []
, txInsCollateral :: TxInsCollateral era
txInsCollateral = TxInsCollateral era
forall era. TxInsCollateral era
TxInsCollateralNone
, txInsReference :: TxInsReference era
txInsReference = TxInsReference era
forall era. TxInsReference era
TxInsReferenceNone
, txOuts :: [TxOut CtxTx era]
txOuts = []
, txTotalCollateral :: TxTotalCollateral era
txTotalCollateral = TxTotalCollateral era
forall era. TxTotalCollateral era
TxTotalCollateralNone
, txReturnCollateral :: TxReturnCollateral CtxTx era
txReturnCollateral = TxReturnCollateral CtxTx era
forall ctx era. TxReturnCollateral ctx era
TxReturnCollateralNone
, txFee :: TxFee era
txFee = ShelleyBasedEra era -> TxFee era
forall era. ShelleyBasedEra era -> TxFee era
defaultTxFee ShelleyBasedEra era
era
, txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound = TxValidityLowerBound era
forall era. TxValidityLowerBound era
TxValidityNoLowerBound
, txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound = ShelleyBasedEra era -> TxValidityUpperBound era
forall era. ShelleyBasedEra era -> TxValidityUpperBound era
defaultTxValidityUpperBound ShelleyBasedEra era
era
, txMetadata :: TxMetadataInEra era
txMetadata = TxMetadataInEra era
forall era. TxMetadataInEra era
TxMetadataNone
, txAuxScripts :: TxAuxScripts era
txAuxScripts = TxAuxScripts era
forall era. TxAuxScripts era
TxAuxScriptsNone
, txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits = TxExtraKeyWitnesses era
forall era. TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone
, txProtocolParams :: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams = Maybe (LedgerProtocolParameters era)
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
forall a. a -> BuildTxWith BuildTx a
BuildTxWith Maybe (LedgerProtocolParameters era)
forall a. Maybe a
Nothing
, txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals = TxWithdrawals BuildTx era
forall build era. TxWithdrawals build era
TxWithdrawalsNone
, txCertificates :: TxCertificates BuildTx era
txCertificates = TxCertificates BuildTx era
forall build era. TxCertificates build era
TxCertificatesNone
, txUpdateProposal :: TxUpdateProposal era
txUpdateProposal = TxUpdateProposal era
forall era. TxUpdateProposal era
TxUpdateProposalNone
, txMintValue :: TxMintValue BuildTx era
txMintValue = TxMintValue BuildTx era
forall build era. TxMintValue build era
TxMintNone
, txScriptValidity :: TxScriptValidity era
txScriptValidity = TxScriptValidity era
forall era. TxScriptValidity era
TxScriptValidityNone
, txProposalProcedures :: Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures = Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
forall a. Maybe a
Nothing
, txVotingProcedures :: Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures = Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
forall a. Maybe a
Nothing
, txCurrentTreasuryValue :: Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue = Maybe (Featured ConwayEraOnwards era (Maybe Coin))
forall a. Maybe a
Nothing
, txTreasuryDonation :: Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation = Maybe (Featured ConwayEraOnwards era Coin)
forall a. Maybe a
Nothing
}
setTxIns :: TxIns build era -> TxBodyContent build era -> TxBodyContent build era
setTxIns :: forall build era.
TxIns build era
-> TxBodyContent build era -> TxBodyContent build era
setTxIns TxIns build era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txIns = v}
modTxIns
:: (TxIns build era -> TxIns build era) -> TxBodyContent build era -> TxBodyContent build era
modTxIns :: forall build era.
(TxIns build era -> TxIns build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxIns TxIns build era -> TxIns build era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txIns = f (txIns txBodyContent)}
addTxIn
:: (TxIn, BuildTxWith build (Witness WitCtxTxIn era))
-> TxBodyContent build era
-> TxBodyContent build era
addTxIn :: forall build era.
(TxIn, BuildTxWith build (Witness WitCtxTxIn era))
-> TxBodyContent build era -> TxBodyContent build era
addTxIn (TxIn, BuildTxWith build (Witness WitCtxTxIn era))
txIn = (TxIns build era -> TxIns build era)
-> TxBodyContent build era -> TxBodyContent build era
forall build era.
(TxIns build era -> TxIns build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxIns ((TxIn, BuildTxWith build (Witness WitCtxTxIn era))
txIn (TxIn, BuildTxWith build (Witness WitCtxTxIn era))
-> TxIns build era -> TxIns build era
forall a. a -> [a] -> [a]
:)
addTxIns :: TxIns build era -> TxBodyContent build era -> TxBodyContent build era
addTxIns :: forall build era.
TxIns build era
-> TxBodyContent build era -> TxBodyContent build era
addTxIns TxIns build era
txIns = (TxIns build era -> TxIns build era)
-> TxBodyContent build era -> TxBodyContent build era
forall build era.
(TxIns build era -> TxIns build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxIns (TxIns build era -> TxIns build era -> TxIns build era
forall a. Semigroup a => a -> a -> a
<> TxIns build era
txIns)
setTxInsCollateral :: TxInsCollateral era -> TxBodyContent build era -> TxBodyContent build era
setTxInsCollateral :: forall era build.
TxInsCollateral era
-> TxBodyContent build era -> TxBodyContent build era
setTxInsCollateral TxInsCollateral era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txInsCollateral = v}
modTxInsCollateral
:: (TxInsCollateral era -> TxInsCollateral era) -> TxBodyContent build era -> TxBodyContent build era
modTxInsCollateral :: forall era build.
(TxInsCollateral era -> TxInsCollateral era)
-> TxBodyContent build era -> TxBodyContent build era
modTxInsCollateral TxInsCollateral era -> TxInsCollateral era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txInsCollateral = f (txInsCollateral txBodyContent)}
addTxInsCollateral
:: IsAlonzoBasedEra era => [TxIn] -> TxBodyContent build era -> TxBodyContent build era
addTxInsCollateral :: forall era build.
IsAlonzoBasedEra era =>
[TxIn] -> TxBodyContent build era -> TxBodyContent build era
addTxInsCollateral [TxIn]
txInsCollateral =
(TxInsCollateral era -> TxInsCollateral era)
-> TxBodyContent build era -> TxBodyContent build era
forall era build.
(TxInsCollateral era -> TxInsCollateral era)
-> TxBodyContent build era -> TxBodyContent build era
modTxInsCollateral
( \case
TxInsCollateral era
TxInsCollateralNone -> AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
forall era. AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
TxInsCollateral AlonzoEraOnwards era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra [TxIn]
txInsCollateral
TxInsCollateral AlonzoEraOnwards era
era [TxIn]
xs -> AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
forall era. AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
TxInsCollateral AlonzoEraOnwards era
era ([TxIn]
xs [TxIn] -> [TxIn] -> [TxIn]
forall a. Semigroup a => a -> a -> a
<> [TxIn]
txInsCollateral)
)
addTxInCollateral
:: IsAlonzoBasedEra era => TxIn -> TxBodyContent build era -> TxBodyContent build era
addTxInCollateral :: forall era build.
IsAlonzoBasedEra era =>
TxIn -> TxBodyContent build era -> TxBodyContent build era
addTxInCollateral TxIn
txInCollateral = [TxIn] -> TxBodyContent build era -> TxBodyContent build era
forall era build.
IsAlonzoBasedEra era =>
[TxIn] -> TxBodyContent build era -> TxBodyContent build era
addTxInsCollateral [TxIn
txInCollateral]
setTxInsReference :: TxInsReference era -> TxBodyContent build era -> TxBodyContent build era
setTxInsReference :: forall era build.
TxInsReference era
-> TxBodyContent build era -> TxBodyContent build era
setTxInsReference TxInsReference era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txInsReference = v}
modTxInsReference
:: (TxInsReference era -> TxInsReference era) -> TxBodyContent build era -> TxBodyContent build era
modTxInsReference :: forall era build.
(TxInsReference era -> TxInsReference era)
-> TxBodyContent build era -> TxBodyContent build era
modTxInsReference TxInsReference era -> TxInsReference era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txInsReference = f (txInsReference txBodyContent)}
addTxInsReference
:: IsBabbageBasedEra era => [TxIn] -> TxBodyContent build era -> TxBodyContent build era
addTxInsReference :: forall era build.
IsBabbageBasedEra era =>
[TxIn] -> TxBodyContent build era -> TxBodyContent build era
addTxInsReference [TxIn]
txInsReference =
(TxInsReference era -> TxInsReference era)
-> TxBodyContent build era -> TxBodyContent build era
forall era build.
(TxInsReference era -> TxInsReference era)
-> TxBodyContent build era -> TxBodyContent build era
modTxInsReference
( \case
TxInsReference era
TxInsReferenceNone -> BabbageEraOnwards era -> [TxIn] -> TxInsReference era
forall era. BabbageEraOnwards era -> [TxIn] -> TxInsReference era
TxInsReference BabbageEraOnwards era
forall era. IsBabbageBasedEra era => BabbageEraOnwards era
babbageBasedEra [TxIn]
txInsReference
TxInsReference BabbageEraOnwards era
era [TxIn]
xs -> BabbageEraOnwards era -> [TxIn] -> TxInsReference era
forall era. BabbageEraOnwards era -> [TxIn] -> TxInsReference era
TxInsReference BabbageEraOnwards era
era ([TxIn]
xs [TxIn] -> [TxIn] -> [TxIn]
forall a. Semigroup a => a -> a -> a
<> [TxIn]
txInsReference)
)
addTxInReference
:: IsBabbageBasedEra era => TxIn -> TxBodyContent build era -> TxBodyContent build era
addTxInReference :: forall era build.
IsBabbageBasedEra era =>
TxIn -> TxBodyContent build era -> TxBodyContent build era
addTxInReference TxIn
txInReference = [TxIn] -> TxBodyContent build era -> TxBodyContent build era
forall era build.
IsBabbageBasedEra era =>
[TxIn] -> TxBodyContent build era -> TxBodyContent build era
addTxInsReference [TxIn
txInReference]
setTxOuts :: [TxOut CtxTx era] -> TxBodyContent build era -> TxBodyContent build era
setTxOuts :: forall era build.
[TxOut CtxTx era]
-> TxBodyContent build era -> TxBodyContent build era
setTxOuts [TxOut CtxTx era]
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txOuts = v}
modTxOuts
:: ([TxOut CtxTx era] -> [TxOut CtxTx era]) -> TxBodyContent build era -> TxBodyContent build era
modTxOuts :: forall era build.
([TxOut CtxTx era] -> [TxOut CtxTx era])
-> TxBodyContent build era -> TxBodyContent build era
modTxOuts [TxOut CtxTx era] -> [TxOut CtxTx era]
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txOuts = f (txOuts txBodyContent)}
addTxOut :: TxOut CtxTx era -> TxBodyContent build era -> TxBodyContent build era
addTxOut :: forall era build.
TxOut CtxTx era
-> TxBodyContent build era -> TxBodyContent build era
addTxOut TxOut CtxTx era
txOut = ([TxOut CtxTx era] -> [TxOut CtxTx era])
-> TxBodyContent build era -> TxBodyContent build era
forall era build.
([TxOut CtxTx era] -> [TxOut CtxTx era])
-> TxBodyContent build era -> TxBodyContent build era
modTxOuts (TxOut CtxTx era
txOut TxOut CtxTx era -> [TxOut CtxTx era] -> [TxOut CtxTx era]
forall a. a -> [a] -> [a]
:)
addTxOuts :: [TxOut CtxTx era] -> TxBodyContent build era -> TxBodyContent build era
addTxOuts :: forall era build.
[TxOut CtxTx era]
-> TxBodyContent build era -> TxBodyContent build era
addTxOuts [TxOut CtxTx era]
txOuts = ([TxOut CtxTx era] -> [TxOut CtxTx era])
-> TxBodyContent build era -> TxBodyContent build era
forall era build.
([TxOut CtxTx era] -> [TxOut CtxTx era])
-> TxBodyContent build era -> TxBodyContent build era
modTxOuts ([TxOut CtxTx era] -> [TxOut CtxTx era] -> [TxOut CtxTx era]
forall a. Semigroup a => a -> a -> a
<> [TxOut CtxTx era]
txOuts)
setTxTotalCollateral :: TxTotalCollateral era -> TxBodyContent build era -> TxBodyContent build era
setTxTotalCollateral :: forall era build.
TxTotalCollateral era
-> TxBodyContent build era -> TxBodyContent build era
setTxTotalCollateral TxTotalCollateral era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txTotalCollateral = v}
modTxTotalCollateral
:: (TxTotalCollateral era -> TxTotalCollateral era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxTotalCollateral :: forall era build.
(TxTotalCollateral era -> TxTotalCollateral era)
-> TxBodyContent build era -> TxBodyContent build era
modTxTotalCollateral TxTotalCollateral era -> TxTotalCollateral era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txTotalCollateral = f (txTotalCollateral txBodyContent)}
setTxReturnCollateral
:: TxReturnCollateral CtxTx era -> TxBodyContent build era -> TxBodyContent build era
setTxReturnCollateral :: forall era build.
TxReturnCollateral CtxTx era
-> TxBodyContent build era -> TxBodyContent build era
setTxReturnCollateral TxReturnCollateral CtxTx era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txReturnCollateral = v}
modTxReturnCollateral
:: (TxReturnCollateral CtxTx era -> TxReturnCollateral CtxTx era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxReturnCollateral :: forall era build.
(TxReturnCollateral CtxTx era -> TxReturnCollateral CtxTx era)
-> TxBodyContent build era -> TxBodyContent build era
modTxReturnCollateral TxReturnCollateral CtxTx era -> TxReturnCollateral CtxTx era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txReturnCollateral = f (txReturnCollateral txBodyContent)}
setTxFee :: TxFee era -> TxBodyContent build era -> TxBodyContent build era
setTxFee :: forall era build.
TxFee era -> TxBodyContent build era -> TxBodyContent build era
setTxFee TxFee era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txFee = v}
modTxFee
:: (TxFee era -> TxFee era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxFee :: forall era build.
(TxFee era -> TxFee era)
-> TxBodyContent build era -> TxBodyContent build era
modTxFee TxFee era -> TxFee era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txFee = f (txFee txBodyContent)}
setTxValidityLowerBound
:: TxValidityLowerBound era -> TxBodyContent build era -> TxBodyContent build era
setTxValidityLowerBound :: forall era build.
TxValidityLowerBound era
-> TxBodyContent build era -> TxBodyContent build era
setTxValidityLowerBound TxValidityLowerBound era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txValidityLowerBound = v}
modTxValidityLowerBound
:: (TxValidityLowerBound era -> TxValidityLowerBound era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxValidityLowerBound :: forall era build.
(TxValidityLowerBound era -> TxValidityLowerBound era)
-> TxBodyContent build era -> TxBodyContent build era
modTxValidityLowerBound TxValidityLowerBound era -> TxValidityLowerBound era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txValidityLowerBound = f (txValidityLowerBound txBodyContent)}
setTxValidityUpperBound
:: TxValidityUpperBound era -> TxBodyContent build era -> TxBodyContent build era
setTxValidityUpperBound :: forall era build.
TxValidityUpperBound era
-> TxBodyContent build era -> TxBodyContent build era
setTxValidityUpperBound TxValidityUpperBound era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txValidityUpperBound = v}
modTxValidityUpperBound
:: (TxValidityUpperBound era -> TxValidityUpperBound era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxValidityUpperBound :: forall era build.
(TxValidityUpperBound era -> TxValidityUpperBound era)
-> TxBodyContent build era -> TxBodyContent build era
modTxValidityUpperBound TxValidityUpperBound era -> TxValidityUpperBound era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txValidityUpperBound = f (txValidityUpperBound txBodyContent)}
setTxMetadata :: TxMetadataInEra era -> TxBodyContent build era -> TxBodyContent build era
setTxMetadata :: forall era build.
TxMetadataInEra era
-> TxBodyContent build era -> TxBodyContent build era
setTxMetadata TxMetadataInEra era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txMetadata = v}
modTxMetadata
:: (TxMetadataInEra era -> TxMetadataInEra era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxMetadata :: forall era build.
(TxMetadataInEra era -> TxMetadataInEra era)
-> TxBodyContent build era -> TxBodyContent build era
modTxMetadata TxMetadataInEra era -> TxMetadataInEra era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txMetadata = f (txMetadata txBodyContent)}
setTxAuxScripts :: TxAuxScripts era -> TxBodyContent build era -> TxBodyContent build era
setTxAuxScripts :: forall era build.
TxAuxScripts era
-> TxBodyContent build era -> TxBodyContent build era
setTxAuxScripts TxAuxScripts era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txAuxScripts = v}
modTxAuxScripts
:: (TxAuxScripts era -> TxAuxScripts era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxAuxScripts :: forall era build.
(TxAuxScripts era -> TxAuxScripts era)
-> TxBodyContent build era -> TxBodyContent build era
modTxAuxScripts TxAuxScripts era -> TxAuxScripts era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txAuxScripts = f (txAuxScripts txBodyContent)}
setTxExtraKeyWits :: TxExtraKeyWitnesses era -> TxBodyContent build era -> TxBodyContent build era
TxExtraKeyWitnesses era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txExtraKeyWits = v}
modTxExtraKeyWits
:: (TxExtraKeyWitnesses era -> TxExtraKeyWitnesses era)
-> TxBodyContent build era
-> TxBodyContent build era
TxExtraKeyWitnesses era -> TxExtraKeyWitnesses era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txExtraKeyWits = f (txExtraKeyWits txBodyContent)}
addTxExtraKeyWits
:: IsAlonzoBasedEra era => [Hash PaymentKey] -> TxBodyContent build era -> TxBodyContent build era
[Hash PaymentKey]
vks =
(TxExtraKeyWitnesses era -> TxExtraKeyWitnesses era)
-> TxBodyContent build era -> TxBodyContent build era
forall era build.
(TxExtraKeyWitnesses era -> TxExtraKeyWitnesses era)
-> TxBodyContent build era -> TxBodyContent build era
modTxExtraKeyWits
( \case
TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone ->
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
forall era.
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
TxExtraKeyWitnesses AlonzoEraOnwards era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra [Hash PaymentKey]
vks
TxExtraKeyWitnesses AlonzoEraOnwards era
era [Hash PaymentKey]
vks' ->
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
forall era.
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
TxExtraKeyWitnesses AlonzoEraOnwards era
era ([Hash PaymentKey]
vks' [Hash PaymentKey] -> [Hash PaymentKey] -> [Hash PaymentKey]
forall a. Semigroup a => a -> a -> a
<> [Hash PaymentKey]
vks)
)
setTxProtocolParams
:: BuildTxWith build (Maybe (LedgerProtocolParameters era))
-> TxBodyContent build era
-> TxBodyContent build era
setTxProtocolParams :: forall build era.
BuildTxWith build (Maybe (LedgerProtocolParameters era))
-> TxBodyContent build era -> TxBodyContent build era
setTxProtocolParams BuildTxWith build (Maybe (LedgerProtocolParameters era))
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txProtocolParams = v}
setTxWithdrawals :: TxWithdrawals build era -> TxBodyContent build era -> TxBodyContent build era
setTxWithdrawals :: forall build era.
TxWithdrawals build era
-> TxBodyContent build era -> TxBodyContent build era
setTxWithdrawals TxWithdrawals build era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txWithdrawals = v}
modTxWithdrawals
:: (TxWithdrawals build era -> TxWithdrawals build era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxWithdrawals :: forall build era.
(TxWithdrawals build era -> TxWithdrawals build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxWithdrawals TxWithdrawals build era -> TxWithdrawals build era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txWithdrawals = f (txWithdrawals txBodyContent)}
setTxCertificates :: TxCertificates build era -> TxBodyContent build era -> TxBodyContent build era
setTxCertificates :: forall build era.
TxCertificates build era
-> TxBodyContent build era -> TxBodyContent build era
setTxCertificates TxCertificates build era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txCertificates = v}
modTxCertificates
:: (TxCertificates build era -> TxCertificates build era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxCertificates :: forall build era.
(TxCertificates build era -> TxCertificates build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxCertificates TxCertificates build era -> TxCertificates build era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txCertificates = f (txCertificates txBodyContent)}
setTxUpdateProposal :: TxUpdateProposal era -> TxBodyContent build era -> TxBodyContent build era
setTxUpdateProposal :: forall era build.
TxUpdateProposal era
-> TxBodyContent build era -> TxBodyContent build era
setTxUpdateProposal TxUpdateProposal era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txUpdateProposal = v}
modTxUpdateProposal
:: (TxUpdateProposal era -> TxUpdateProposal era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxUpdateProposal :: forall era build.
(TxUpdateProposal era -> TxUpdateProposal era)
-> TxBodyContent build era -> TxBodyContent build era
modTxUpdateProposal TxUpdateProposal era -> TxUpdateProposal era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txUpdateProposal = f (txUpdateProposal txBodyContent)}
setTxMintValue :: TxMintValue build era -> TxBodyContent build era -> TxBodyContent build era
setTxMintValue :: forall build era.
TxMintValue build era
-> TxBodyContent build era -> TxBodyContent build era
setTxMintValue TxMintValue build era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txMintValue = v}
modTxMintValue
:: (TxMintValue build era -> TxMintValue build era)
-> TxBodyContent build era
-> TxBodyContent build era
modTxMintValue :: forall build era.
(TxMintValue build era -> TxMintValue build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxMintValue TxMintValue build era -> TxMintValue build era
f TxBodyContent build era
tx = TxBodyContent build era
tx{txMintValue = f (txMintValue tx)}
addTxMintValue
:: IsMaryBasedEra era
=> Map PolicyId [(AssetName, Quantity, BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxBodyContent build era
-> TxBodyContent build era
addTxMintValue :: forall era build.
IsMaryBasedEra era =>
Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxBodyContent build era -> TxBodyContent build era
addTxMintValue Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets =
(TxMintValue build era -> TxMintValue build era)
-> TxBodyContent build era -> TxBodyContent build era
forall build era.
(TxMintValue build era -> TxMintValue build era)
-> TxBodyContent build era -> TxBodyContent build era
modTxMintValue
( \case
TxMintValue build era
TxMintNone -> MaryEraOnwards era
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxMintValue build era
forall era build.
MaryEraOnwards era
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxMintValue build era
TxMintValue MaryEraOnwards era
forall era. IsMaryBasedEra era => MaryEraOnwards era
maryBasedEra Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets
TxMintValue MaryEraOnwards era
era Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
t -> MaryEraOnwards era
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxMintValue build era
forall era build.
MaryEraOnwards era
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxMintValue build era
TxMintValue MaryEraOnwards era
era (Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
t Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
forall a. Semigroup a => a -> a -> a
<> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets)
)
subtractTxMintValue
:: IsMaryBasedEra era
=> Map PolicyId [(AssetName, Quantity, BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxBodyContent build era
-> TxBodyContent build era
subtractTxMintValue :: forall era build.
IsMaryBasedEra era =>
Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxBodyContent build era -> TxBodyContent build era
subtractTxMintValue Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets = Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxBodyContent build era -> TxBodyContent build era
forall era build.
IsMaryBasedEra era =>
Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxBodyContent build era -> TxBodyContent build era
addTxMintValue (([(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))])
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
forall a b. (a -> b) -> Map PolicyId a -> Map PolicyId b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (((AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))
-> (AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era)))
-> [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> [(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
forall a b. (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(AssetName
x, Quantity
y, BuildTxWith build (ScriptWitness WitCtxMint era)
z) -> (AssetName
x, Quantity -> Quantity
forall a. Num a => a -> a
negate Quantity
y, BuildTxWith build (ScriptWitness WitCtxMint era)
z))) Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
assets)
setTxScriptValidity :: TxScriptValidity era -> TxBodyContent build era -> TxBodyContent build era
setTxScriptValidity :: forall era build.
TxScriptValidity era
-> TxBodyContent build era -> TxBodyContent build era
setTxScriptValidity TxScriptValidity era
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txScriptValidity = v}
modTxScriptValidity
:: (TxScriptValidity era -> TxScriptValidity era) -> TxBodyContent build era -> TxBodyContent build era
modTxScriptValidity :: forall era build.
(TxScriptValidity era -> TxScriptValidity era)
-> TxBodyContent build era -> TxBodyContent build era
modTxScriptValidity TxScriptValidity era -> TxScriptValidity era
f TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txScriptValidity = f (txScriptValidity txBodyContent)}
setTxProposalProcedures
:: Maybe (Featured ConwayEraOnwards era (TxProposalProcedures build era))
-> TxBodyContent build era
-> TxBodyContent build era
setTxProposalProcedures :: forall era build.
Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures build era))
-> TxBodyContent build era -> TxBodyContent build era
setTxProposalProcedures Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures build era))
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txProposalProcedures = v}
setTxVotingProcedures
:: Maybe (Featured ConwayEraOnwards era (TxVotingProcedures build era))
-> TxBodyContent build era
-> TxBodyContent build era
setTxVotingProcedures :: forall era build.
Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures build era))
-> TxBodyContent build era -> TxBodyContent build era
setTxVotingProcedures Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures build era))
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txVotingProcedures = v}
setTxCurrentTreasuryValue
:: Maybe (Featured ConwayEraOnwards era (Maybe L.Coin))
-> TxBodyContent build era
-> TxBodyContent build era
setTxCurrentTreasuryValue :: forall era build.
Maybe (Featured ConwayEraOnwards era (Maybe Coin))
-> TxBodyContent build era -> TxBodyContent build era
setTxCurrentTreasuryValue Maybe (Featured ConwayEraOnwards era (Maybe Coin))
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txCurrentTreasuryValue = v}
setTxTreasuryDonation
:: Maybe (Featured ConwayEraOnwards era L.Coin) -> TxBodyContent build era -> TxBodyContent build era
setTxTreasuryDonation :: forall era build.
Maybe (Featured ConwayEraOnwards era Coin)
-> TxBodyContent build era -> TxBodyContent build era
setTxTreasuryDonation Maybe (Featured ConwayEraOnwards era Coin)
v TxBodyContent build era
txBodyContent = TxBodyContent build era
txBodyContent{txTreasuryDonation = v}
getTxIdByron :: Byron.ATxAux ByteString -> TxId
getTxIdByron :: ATxAux ByteString -> TxId
getTxIdByron (Byron.ATxAux{aTaTx :: forall a. ATxAux a -> Annotated Tx a
Byron.aTaTx = Annotated Tx ByteString
txbody}) =
Hash Blake2b_256 EraIndependentTxBody -> TxId
Hash StandardCrypto EraIndependentTxBody -> TxId
TxId
(Hash Blake2b_256 EraIndependentTxBody -> TxId)
-> (Annotated Tx ByteString
-> Hash Blake2b_256 EraIndependentTxBody)
-> Annotated Tx ByteString
-> TxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_256 EraIndependentTxBody
-> Maybe (Hash Blake2b_256 EraIndependentTxBody)
-> Hash Blake2b_256 EraIndependentTxBody
forall a. a -> Maybe a -> a
fromMaybe Hash Blake2b_256 EraIndependentTxBody
forall {a}. a
impossible
(Maybe (Hash Blake2b_256 EraIndependentTxBody)
-> Hash Blake2b_256 EraIndependentTxBody)
-> (Annotated Tx ByteString
-> Maybe (Hash Blake2b_256 EraIndependentTxBody))
-> Annotated Tx ByteString
-> Hash Blake2b_256 EraIndependentTxBody
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ShortByteString -> Maybe (Hash Blake2b_256 EraIndependentTxBody)
forall h a. HashAlgorithm h => ShortByteString -> Maybe (Hash h a)
Crypto.hashFromBytesShort
(ShortByteString -> Maybe (Hash Blake2b_256 EraIndependentTxBody))
-> (Annotated Tx ByteString -> ShortByteString)
-> Annotated Tx ByteString
-> Maybe (Hash Blake2b_256 EraIndependentTxBody)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AbstractHash Blake2b_256 Tx -> ShortByteString
forall algo a. AbstractHash algo a -> ShortByteString
Byron.abstractHashToShort
(AbstractHash Blake2b_256 Tx -> ShortByteString)
-> (Annotated Tx ByteString -> AbstractHash Blake2b_256 Tx)
-> Annotated Tx ByteString
-> ShortByteString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Annotated Tx ByteString
-> Hash (BaseType (Annotated Tx ByteString))
Annotated Tx ByteString -> AbstractHash Blake2b_256 Tx
forall t. Decoded t => t -> Hash (BaseType t)
Byron.hashDecoded
(Annotated Tx ByteString -> TxId)
-> Annotated Tx ByteString -> TxId
forall a b. (a -> b) -> a -> b
$ Annotated Tx ByteString
txbody
where
impossible :: a
impossible =
String -> a
forall a. HasCallStack => String -> a
error String
"getTxIdByron: byron and shelley hash sizes do not match"
getTxId :: TxBody era -> TxId
getTxId :: forall era. TxBody era -> TxId
getTxId (ShelleyTxBody ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
tx [Script (ShelleyLedgerEra era)]
_ TxBodyScriptData era
_ Maybe (TxAuxData (ShelleyLedgerEra era))
_ TxScriptValidity era
_) =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxId) -> TxId
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxId) -> TxId)
-> (ShelleyBasedEraConstraints era => TxId) -> TxId
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era -> TxBody (ShelleyLedgerEra era) -> TxId
forall era.
(EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto,
EraTxBody (ShelleyLedgerEra era)) =>
ShelleyBasedEra era -> TxBody (ShelleyLedgerEra era) -> TxId
getTxIdShelley ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
tx
getTxIdShelley
:: Ledger.EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto
=> Ledger.EraTxBody (ShelleyLedgerEra era)
=> ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxId
getTxIdShelley :: forall era.
(EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto,
EraTxBody (ShelleyLedgerEra era)) =>
ShelleyBasedEra era -> TxBody (ShelleyLedgerEra era) -> TxId
getTxIdShelley ShelleyBasedEra era
_ TxBody (ShelleyLedgerEra era)
tx =
Hash Blake2b_256 EraIndependentTxBody -> TxId
Hash StandardCrypto EraIndependentTxBody -> TxId
TxId
(Hash Blake2b_256 EraIndependentTxBody -> TxId)
-> (TxId (EraCrypto (ShelleyLedgerEra era))
-> Hash Blake2b_256 EraIndependentTxBody)
-> TxId (EraCrypto (ShelleyLedgerEra era))
-> TxId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hash Blake2b_256 EraIndependentTxBody
-> Hash Blake2b_256 EraIndependentTxBody
forall h a b. Hash h a -> Hash h b
Crypto.castHash
(Hash Blake2b_256 EraIndependentTxBody
-> Hash Blake2b_256 EraIndependentTxBody)
-> (TxId (EraCrypto (ShelleyLedgerEra era))
-> Hash Blake2b_256 EraIndependentTxBody)
-> TxId (EraCrypto (ShelleyLedgerEra era))
-> Hash Blake2b_256 EraIndependentTxBody
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (\(Ledger.TxId SafeHash (EraCrypto (ShelleyLedgerEra era)) EraIndependentTxBody
txhash) -> SafeHash (EraCrypto (ShelleyLedgerEra era)) EraIndependentTxBody
-> Hash
(HASH (EraCrypto (ShelleyLedgerEra era))) EraIndependentTxBody
forall c i. SafeHash c i -> Hash (HASH c) i
SafeHash.extractHash SafeHash (EraCrypto (ShelleyLedgerEra era)) EraIndependentTxBody
txhash)
(TxId (EraCrypto (ShelleyLedgerEra era)) -> TxId)
-> TxId (EraCrypto (ShelleyLedgerEra era)) -> TxId
forall a b. (a -> b) -> a -> b
$ TxBody (ShelleyLedgerEra era)
-> TxId (EraCrypto (ShelleyLedgerEra era))
forall era. EraTxBody era => TxBody era -> TxId (EraCrypto era)
Ledger.txIdTxBody TxBody (ShelleyLedgerEra era)
tx
data TxBodyError
= TxBodyEmptyTxIns
| TxBodyEmptyTxInsCollateral
| TxBodyEmptyTxOuts
| TxBodyOutputNegative !Quantity !TxOutInAnyEra
| TxBodyOutputOverflow !Quantity !TxOutInAnyEra
| TxBodyMetadataError ![(Word64, TxMetadataRangeError)]
| TxBodyInIxOverflow !TxIn
| TxBodyMissingProtocolParams
| TxBodyProtocolParamsConversionError !ProtocolParametersConversionError
deriving (TxBodyError -> TxBodyError -> Bool
(TxBodyError -> TxBodyError -> Bool)
-> (TxBodyError -> TxBodyError -> Bool) -> Eq TxBodyError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxBodyError -> TxBodyError -> Bool
== :: TxBodyError -> TxBodyError -> Bool
$c/= :: TxBodyError -> TxBodyError -> Bool
/= :: TxBodyError -> TxBodyError -> Bool
Eq, Int -> TxBodyError -> ShowS
[TxBodyError] -> ShowS
TxBodyError -> String
(Int -> TxBodyError -> ShowS)
-> (TxBodyError -> String)
-> ([TxBodyError] -> ShowS)
-> Show TxBodyError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxBodyError -> ShowS
showsPrec :: Int -> TxBodyError -> ShowS
$cshow :: TxBodyError -> String
show :: TxBodyError -> String
$cshowList :: [TxBodyError] -> ShowS
showList :: [TxBodyError] -> ShowS
Show)
instance Error TxBodyError where
prettyError :: forall ann. TxBodyError -> Doc ann
prettyError = \case
TxBodyError
TxBodyEmptyTxIns ->
Doc ann
"Transaction body has no inputs"
TxBodyError
TxBodyEmptyTxInsCollateral ->
Doc ann
"Transaction body has no collateral inputs, but uses Plutus scripts"
TxBodyError
TxBodyEmptyTxOuts ->
Doc ann
"Transaction body has no outputs"
TxBodyOutputNegative (Quantity Integer
q) TxOutInAnyEra
txout ->
Doc ann
"Negative quantity ("
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
q
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
") in transaction output: "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> TxOutInAnyEra -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. TxOutInAnyEra -> Doc ann
pretty TxOutInAnyEra
txout
TxBodyOutputOverflow (Quantity Integer
q) TxOutInAnyEra
txout ->
Doc ann
"Quantity too large ("
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
q
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
" >= 2^64) in transaction output: "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> TxOutInAnyEra -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. TxOutInAnyEra -> Doc ann
pretty TxOutInAnyEra
txout
TxBodyMetadataError [(Word64
k, TxMetadataRangeError
err)] ->
Doc ann
"Error in metadata entry " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Word64 -> Doc ann
forall ann. Word64 -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Word64
k Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
": " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> TxMetadataRangeError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. TxMetadataRangeError -> Doc ann
prettyError TxMetadataRangeError
err
TxBodyMetadataError [(Word64, TxMetadataRangeError)]
errs ->
[Doc ann] -> Doc ann
forall a. Monoid a => [a] -> a
mconcat
[ Doc ann
"Error in metadata entries: "
, [Doc ann] -> Doc ann
forall a. Monoid a => [a] -> a
mconcat ([Doc ann] -> Doc ann) -> [Doc ann] -> Doc ann
forall a b. (a -> b) -> a -> b
$
Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
List.intersperse
Doc ann
"; "
[ Word64 -> Doc ann
forall ann. Word64 -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Word64
k Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
": " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> TxMetadataRangeError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. TxMetadataRangeError -> Doc ann
prettyError TxMetadataRangeError
err
| (Word64
k, TxMetadataRangeError
err) <- [(Word64, TxMetadataRangeError)]
errs
]
]
TxBodyError
TxBodyMissingProtocolParams ->
Doc ann
"Transaction uses Plutus scripts but does not provide the protocol "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"parameters to hash"
TxBodyInIxOverflow TxIn
txin ->
Doc ann
"Transaction input index is too big, "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"acceptable value is up to 2^32-1, "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"in input "
Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> TxIn -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. TxIn -> Doc ann
pretty TxIn
txin
TxBodyProtocolParamsConversionError ProtocolParametersConversionError
ppces ->
Doc ann
"Errors in protocol parameters conversion: " Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> ProtocolParametersConversionError -> Doc ann
forall e ann. Error e => e -> Doc ann
forall ann. ProtocolParametersConversionError -> Doc ann
prettyError ProtocolParametersConversionError
ppces
createTransactionBody
:: ()
=> ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> Either TxBodyError (TxBody era)
createTransactionBody :: forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
createTransactionBody ShelleyBasedEra era
sbe TxBodyContent BuildTx era
bc =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era =>
Either TxBodyError (TxBody era))
-> Either TxBodyError (TxBody era)
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era =>
Either TxBodyError (TxBody era))
-> Either TxBodyError (TxBody era))
-> (ShelleyBasedEraConstraints era =>
Either TxBodyError (TxBody era))
-> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$ do
let era :: CardanoEra era
era = ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe
apiTxOuts :: [TxOut CtxTx era]
apiTxOuts = TxBodyContent BuildTx era -> [TxOut CtxTx era]
forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts TxBodyContent BuildTx era
bc
apiScriptWitnesses :: [(ScriptWitnessIndex, AnyScriptWitness era)]
apiScriptWitnesses = ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
sbe TxBodyContent BuildTx era
bc
apiScriptValidity :: TxScriptValidity era
apiScriptValidity = TxBodyContent BuildTx era -> TxScriptValidity era
forall build era. TxBodyContent build era -> TxScriptValidity era
txScriptValidity TxBodyContent BuildTx era
bc
apiMintValue :: TxMintValue BuildTx era
apiMintValue = TxBodyContent BuildTx era -> TxMintValue BuildTx era
forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue TxBodyContent BuildTx era
bc
apiProtocolParameters :: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
apiProtocolParameters = TxBodyContent BuildTx era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
txProtocolParams TxBodyContent BuildTx era
bc
apiCollateralTxIns :: TxInsCollateral era
apiCollateralTxIns = TxBodyContent BuildTx era -> TxInsCollateral era
forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral TxBodyContent BuildTx era
bc
apiReferenceInputs :: TxInsReference era
apiReferenceInputs = TxBodyContent BuildTx era -> TxInsReference era
forall build era. TxBodyContent build era -> TxInsReference era
txInsReference TxBodyContent BuildTx era
bc
apiExtraKeyWitnesses :: TxExtraKeyWitnesses era
apiExtraKeyWitnesses = TxBodyContent BuildTx era -> TxExtraKeyWitnesses era
forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txExtraKeyWits TxBodyContent BuildTx era
bc
apiReturnCollateral :: TxReturnCollateral CtxTx era
apiReturnCollateral = TxBodyContent BuildTx era -> TxReturnCollateral CtxTx era
forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txReturnCollateral TxBodyContent BuildTx era
bc
apiTotalCollateral :: TxTotalCollateral era
apiTotalCollateral = TxBodyContent BuildTx era -> TxTotalCollateral era
forall build era. TxBodyContent build era -> TxTotalCollateral era
txTotalCollateral TxBodyContent BuildTx era
bc
collTxIns :: Set (TxIn StandardCrypto)
collTxIns = TxInsCollateral era -> Set (TxIn StandardCrypto)
forall era. TxInsCollateral era -> Set (TxIn StandardCrypto)
convCollateralTxIns TxInsCollateral era
apiCollateralTxIns
refTxIns :: Set (TxIn StandardCrypto)
refTxIns = TxInsReference era -> Set (TxIn StandardCrypto)
forall era. TxInsReference era -> Set (TxIn StandardCrypto)
convReferenceInputs TxInsReference era
apiReferenceInputs
returnCollateral :: StrictMaybe (TxOut (ShelleyLedgerEra era))
returnCollateral = ShelleyBasedEra era
-> TxReturnCollateral CtxTx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall era ctx.
ShelleyBasedEra era
-> TxReturnCollateral ctx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
convReturnCollateral ShelleyBasedEra era
sbe TxReturnCollateral CtxTx era
apiReturnCollateral
totalCollateral :: StrictMaybe Coin
totalCollateral = TxTotalCollateral era -> StrictMaybe Coin
forall era. TxTotalCollateral era -> StrictMaybe Coin
convTotalCollateral TxTotalCollateral era
apiTotalCollateral
certs :: StrictSeq (TxCert (ShelleyLedgerEra era))
certs = ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe (TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era)))
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ TxBodyContent BuildTx era -> TxCertificates BuildTx era
forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates TxBodyContent BuildTx era
bc
txAuxData :: Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe (TxBodyContent BuildTx era -> TxMetadataInEra era
forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata TxBodyContent BuildTx era
bc) (TxBodyContent BuildTx era -> TxAuxScripts era
forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts TxBodyContent BuildTx era
bc)
scripts :: [Script (ShelleyLedgerEra era)]
scripts = [(ScriptWitnessIndex, AnyScriptWitness era)]
-> [Script (ShelleyLedgerEra era)]
forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
[(ScriptWitnessIndex, AnyScriptWitness era)] -> [Script ledgerera]
convScripts [(ScriptWitnessIndex, AnyScriptWitness era)]
apiScriptWitnesses
languages :: Set Language
languages = [(ScriptWitnessIndex, AnyScriptWitness era)] -> Set Language
forall era.
[(ScriptWitnessIndex, AnyScriptWitness era)] -> Set Language
convLanguages [(ScriptWitnessIndex, AnyScriptWitness era)]
apiScriptWitnesses
sData :: TxBodyScriptData era
sData = ShelleyBasedEra era
-> [TxOut CtxTx era]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
-> TxBodyScriptData era
forall era.
ShelleyBasedEra era
-> [TxOut CtxTx era]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
-> TxBodyScriptData era
convScriptData ShelleyBasedEra era
sbe [TxOut CtxTx era]
apiTxOuts [(ScriptWitnessIndex, AnyScriptWitness era)]
apiScriptWitnesses
proposalProcedures :: OSet (ProposalProcedure (ShelleyLedgerEra era))
proposalProcedures = TxProposalProcedures BuildTx era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall build era.
TxProposalProcedures build era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures (TxProposalProcedures BuildTx era
-> OSet (ProposalProcedure (ShelleyLedgerEra era)))
-> TxProposalProcedures BuildTx era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ TxProposalProcedures BuildTx era
-> (Featured
ConwayEraOnwards era (TxProposalProcedures BuildTx era)
-> TxProposalProcedures BuildTx era)
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
-> TxProposalProcedures BuildTx era
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TxProposalProcedures BuildTx era
forall build era. TxProposalProcedures build era
TxProposalProceduresNone Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era)
-> TxProposalProcedures BuildTx era
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (TxBodyContent BuildTx era
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures build era))
txProposalProcedures TxBodyContent BuildTx era
bc)
votingProcedures :: VotingProcedures (ShelleyLedgerEra era)
votingProcedures = TxVotingProcedures BuildTx era
-> VotingProcedures (ShelleyLedgerEra era)
forall build era.
TxVotingProcedures build era
-> VotingProcedures (ShelleyLedgerEra era)
convVotingProcedures (TxVotingProcedures BuildTx era
-> VotingProcedures (ShelleyLedgerEra era))
-> TxVotingProcedures BuildTx era
-> VotingProcedures (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$ TxVotingProcedures BuildTx era
-> (Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era)
-> TxVotingProcedures BuildTx era)
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
-> TxVotingProcedures BuildTx era
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TxVotingProcedures BuildTx era
forall build era. TxVotingProcedures build era
TxVotingProceduresNone Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era)
-> TxVotingProcedures BuildTx era
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (TxBodyContent BuildTx era
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures build era))
txVotingProcedures TxBodyContent BuildTx era
bc)
currentTreasuryValue :: StrictMaybe Coin
currentTreasuryValue = Maybe Coin -> StrictMaybe Coin
forall a. Maybe a -> StrictMaybe a
Ledger.maybeToStrictMaybe (Maybe Coin -> StrictMaybe Coin) -> Maybe Coin -> StrictMaybe Coin
forall a b. (a -> b) -> a -> b
$ Featured ConwayEraOnwards era (Maybe Coin) -> Maybe Coin
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (Featured ConwayEraOnwards era (Maybe Coin) -> Maybe Coin)
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin)) -> Maybe Coin
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< TxBodyContent BuildTx era
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
forall build era.
TxBodyContent build era
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue TxBodyContent BuildTx era
bc
treasuryDonation :: Coin
treasuryDonation = Coin
-> (Featured ConwayEraOnwards era Coin -> Coin)
-> Maybe (Featured ConwayEraOnwards era Coin)
-> Coin
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Coin
0 Featured ConwayEraOnwards era Coin -> Coin
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (Maybe (Featured ConwayEraOnwards era Coin) -> Coin)
-> Maybe (Featured ConwayEraOnwards era Coin) -> Coin
forall a b. (a -> b) -> a -> b
$ TxBodyContent BuildTx era
-> Maybe (Featured ConwayEraOnwards era Coin)
forall build era.
TxBodyContent build era
-> Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation TxBodyContent BuildTx era
bc
Endo (TxBody era)
setUpdateProposal <- CardanoEra era
-> (ShelleyToBabbageEra era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((ShelleyToBabbageEra era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (ShelleyToBabbageEra era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \ShelleyToBabbageEra era
w ->
(TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (StrictMaybe (Update (ShelleyLedgerEra era))
-> TxBody era -> TxBody era)
-> StrictMaybe (Update (ShelleyLedgerEra era))
-> Endo (TxBody era)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
A.updateTxBodyL ShelleyToBabbageEra era
w ((StrictMaybe (Update (ShelleyLedgerEra era))
-> Identity (StrictMaybe (Update (ShelleyLedgerEra era))))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (Update (ShelleyLedgerEra era))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~) (StrictMaybe (Update (ShelleyLedgerEra era)) -> Endo (TxBody era))
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
-> Either TxBodyError (Endo (TxBody era))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe (TxBodyContent BuildTx era -> TxUpdateProposal era
forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal TxBodyContent BuildTx era
bc)
Endo (TxBody era)
setInvalidBefore <- CardanoEra era
-> (AllegraEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((AllegraEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (AllegraEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \AllegraEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
w ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxValidityLowerBound era -> Maybe SlotNo
forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound (TxBodyContent BuildTx era -> TxValidityLowerBound era
forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound TxBodyContent BuildTx era
bc)
Endo (TxBody era)
setMint <- CardanoEra era
-> (MaryEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((MaryEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (MaryEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \MaryEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
forall era.
MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
A.mintTxBodyL MaryEraOnwards era
w ((MultiAsset StandardCrypto
-> Identity (MultiAsset StandardCrypto))
-> TxBody era -> Identity (TxBody era))
-> MultiAsset StandardCrypto -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxMintValue BuildTx era -> MultiAsset StandardCrypto
forall build era.
TxMintValue build era -> MultiAsset StandardCrypto
convMintValue TxMintValue BuildTx era
apiMintValue
Endo (TxBody era)
setScriptIntegrityHash <- CardanoEra era
-> (AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \AlonzoEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$
(TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$
AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
A.scriptIntegrityHashTxBodyL AlonzoEraOnwards era
w ((StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> Identity (StrictMaybe (ScriptIntegrityHash StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language
-> TxBodyScriptData era
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
forall era.
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language
-> TxBodyScriptData era
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
getScriptIntegrityHash BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
apiProtocolParameters Set Language
languages TxBodyScriptData era
sData
Endo (TxBody era)
setCollateralInputs <- CardanoEra era
-> (AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \AlonzoEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.collateralInputsTxBodyL AlonzoEraOnwards era
w ((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Set (TxIn StandardCrypto)
collTxIns
Endo (TxBody era)
setReqSignerHashes <- CardanoEra era
-> (AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (AlonzoEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \AlonzoEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
A.reqSignerHashesTxBodyL AlonzoEraOnwards era
w ((Set (KeyHash 'Witness StandardCrypto)
-> Identity (Set (KeyHash 'Witness StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (KeyHash 'Witness StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
forall era.
TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
convExtraKeyWitnesses TxExtraKeyWitnesses era
apiExtraKeyWitnesses
Endo (TxBody era)
setReferenceInputs <- CardanoEra era
-> (BabbageEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((BabbageEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (BabbageEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \BabbageEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
BabbageEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.referenceInputsTxBodyL BabbageEraOnwards era
w ((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Set (TxIn StandardCrypto)
refTxIns
Endo (TxBody era)
setCollateralReturn <- CardanoEra era
-> (BabbageEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((BabbageEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (BabbageEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \BabbageEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards era
-> Lens' (TxBody era) (StrictMaybe (TxOut (ShelleyLedgerEra era)))
forall era.
BabbageEraOnwards era
-> Lens' (TxBody era) (StrictMaybe (TxOut (ShelleyLedgerEra era)))
A.collateralReturnTxBodyL BabbageEraOnwards era
w ((StrictMaybe (TxOut (ShelleyLedgerEra era))
-> Identity (StrictMaybe (TxOut (ShelleyLedgerEra era))))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (TxOut (ShelleyLedgerEra era))
returnCollateral
Endo (TxBody era)
setTotalCollateral <- CardanoEra era
-> (BabbageEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((BabbageEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (BabbageEraOnwards era
-> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \BabbageEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
forall era.
BabbageEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
A.totalCollateralTxBodyL BabbageEraOnwards era
w ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
totalCollateral
Endo (TxBody era)
setProposalProcedures <- CardanoEra era
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era
-> Lens'
(TxBody era) (OSet (ProposalProcedure (ShelleyLedgerEra era)))
forall era.
ConwayEraOnwards era
-> Lens'
(TxBody era) (OSet (ProposalProcedure (ShelleyLedgerEra era)))
A.proposalProceduresTxBodyL ConwayEraOnwards era
w ((OSet (ProposalProcedure (ShelleyLedgerEra era))
-> Identity (OSet (ProposalProcedure (ShelleyLedgerEra era))))
-> TxBody era -> Identity (TxBody era))
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ OSet (ProposalProcedure (ShelleyLedgerEra era))
proposalProcedures
Endo (TxBody era)
setVotingProcedures <- CardanoEra era
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era
-> Lens' (TxBody era) (VotingProcedures (ShelleyLedgerEra era))
forall era.
ConwayEraOnwards era
-> Lens' (TxBody era) (VotingProcedures (ShelleyLedgerEra era))
A.votingProceduresTxBodyL ConwayEraOnwards era
w ((VotingProcedures (ShelleyLedgerEra era)
-> Identity (VotingProcedures (ShelleyLedgerEra era)))
-> TxBody era -> Identity (TxBody era))
-> VotingProcedures (ShelleyLedgerEra era)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ VotingProcedures (ShelleyLedgerEra era)
votingProcedures
Endo (TxBody era)
setCurrentTreasuryValue <- CardanoEra era
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
forall era.
ConwayEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
A.currentTreasuryValueTxBodyL ConwayEraOnwards era
w ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe Coin
currentTreasuryValue
Endo (TxBody era)
setTreasuryDonation <- CardanoEra era
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall (eon :: * -> *) (f :: * -> *) a era.
(Eon eon, Applicative f, Monoid a) =>
CardanoEra era -> (eon era -> f a) -> f a
monoidForEraInEonA CardanoEra era
era ((ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era)))
-> (ConwayEraOnwards era -> Either TxBodyError (Endo (TxBody era)))
-> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era)))
-> Endo (TxBody era) -> Either TxBodyError (Endo (TxBody era))
forall a b. (a -> b) -> a -> b
$ (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a. (a -> a) -> Endo a
Endo ((TxBody era -> TxBody era) -> Endo (TxBody era))
-> (TxBody era -> TxBody era) -> Endo (TxBody era)
forall a b. (a -> b) -> a -> b
$ ConwayEraOnwards era -> Lens' (TxBody era) Coin
forall era. ConwayEraOnwards era -> Lens' (TxBody era) Coin
A.treasuryDonationTxBodyL ConwayEraOnwards era
w ((Coin -> Identity Coin) -> TxBody era -> Identity (TxBody era))
-> Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin
treasuryDonation
let ledgerTxBody :: TxBody era
ledgerTxBody =
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe (TxBodyContent BuildTx era -> TxIns BuildTx era
forall build era. TxBodyContent build era -> TxIns build era
txIns TxBodyContent BuildTx era
bc) (TxBodyContent BuildTx era -> [TxOut CtxTx era]
forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts TxBodyContent BuildTx era
bc) (TxBodyContent BuildTx era -> TxFee era
forall build era. TxBodyContent build era -> TxFee era
txFee TxBodyContent BuildTx era
bc) (TxBodyContent BuildTx era -> TxWithdrawals BuildTx era
forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals TxBodyContent BuildTx era
bc) Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (TxCert (ShelleyLedgerEra era))
-> Identity (StrictSeq (TxCert (ShelleyLedgerEra era))))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (TxCert (ShelleyLedgerEra era))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictSeq (TxCert (ShelleyLedgerEra era))
certs
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe (TxBodyContent BuildTx era -> TxValidityUpperBound era
forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound TxBodyContent BuildTx era
bc)
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& Endo (TxBody era) -> TxBody era -> TxBody era
forall a. Endo a -> a -> a
appEndo
( [Endo (TxBody era)] -> Endo (TxBody era)
forall a. Monoid a => [a] -> a
mconcat
[ Endo (TxBody era)
setUpdateProposal
, Endo (TxBody era)
setInvalidBefore
, Endo (TxBody era)
setMint
, Endo (TxBody era)
setScriptIntegrityHash
, Endo (TxBody era)
setCollateralInputs
, Endo (TxBody era)
setReqSignerHashes
, Endo (TxBody era)
setReferenceInputs
, Endo (TxBody era)
setCollateralReturn
, Endo (TxBody era)
setTotalCollateral
, Endo (TxBody era)
setProposalProcedures
, Endo (TxBody era)
setVotingProcedures
, Endo (TxBody era)
setCurrentTreasuryValue
, Endo (TxBody era)
setTreasuryDonation
]
)
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody ShelleyBasedEra era
sbe (TxBody era
ledgerTxBody TxBody era
-> Getting
(TxBody (ShelleyLedgerEra era))
(TxBody era)
(TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall s a. s -> Getting a s a -> a
^. Getting
(TxBody (ShelleyLedgerEra era))
(TxBody era)
(TxBody (ShelleyLedgerEra era))
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL) [Script (ShelleyLedgerEra era)]
scripts TxBodyScriptData era
sData Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData TxScriptValidity era
apiScriptValidity
getScriptIntegrityHash
:: ()
=> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Plutus.Language
-> TxBodyScriptData era
-> StrictMaybe (L.ScriptIntegrityHash (Ledger.EraCrypto (ShelleyLedgerEra era)))
getScriptIntegrityHash :: forall era.
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language
-> TxBodyScriptData era
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
getScriptIntegrityHash BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
apiProtocolParameters Set Language
languages = \case
TxBodyScriptData era
TxBodyNoScriptData -> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
forall a. StrictMaybe a
SNothing
TxBodyScriptData AlonzoEraOnwards era
w TxDats (ShelleyLedgerEra era)
datums Redeemers (ShelleyLedgerEra era)
redeemers ->
AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
forall era.
AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
convPParamsToScriptIntegrityHash AlonzoEraOnwards era
w BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
apiProtocolParameters Redeemers (ShelleyLedgerEra era)
redeemers TxDats (ShelleyLedgerEra era)
datums Set Language
languages
validateTxBodyContent
:: ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> Either TxBodyError ()
validateTxBodyContent :: forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent
ShelleyBasedEra era
sbe
txBodContent :: TxBodyContent BuildTx era
txBodContent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, TxInsCollateral era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral :: TxInsCollateral era
txInsCollateral
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
txProtocolParams :: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
} =
let witnesses :: [(ScriptWitnessIndex, AnyScriptWitness era)]
witnesses = ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txBodContent
languages :: Set Language
languages =
[Item (Set Language)] -> Set Language
forall l. IsList l => [Item l] -> l
fromList
[ AnyPlutusScriptVersion -> Language
toAlonzoLanguage (PlutusScriptVersion lang -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion lang
v)
| (ScriptWitnessIndex
_, AnyScriptWitness (PlutusScriptWitness ScriptLanguageInEra lang era
_ PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
_ ExecutionUnits
_)) <- [(ScriptWitnessIndex, AnyScriptWitness era)]
witnesses
]
:: Set Plutus.Language
in case ShelleyBasedEra era
sbe of
ShelleyBasedEra era
ShelleyBasedEraShelley -> do
TxIns BuildTx era -> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns TxIns BuildTx era
txIns
[TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn)
-> TxIns BuildTx era -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst TxIns BuildTx era
txIns)
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts
TxMetadataInEra era -> Either TxBodyError ()
forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata
ShelleyBasedEra era
ShelleyBasedEraAllegra -> do
TxIns BuildTx era -> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns TxIns BuildTx era
txIns
[TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn)
-> TxIns BuildTx era -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst TxIns BuildTx era
txIns)
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts
TxMetadataInEra era -> Either TxBodyError ()
forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata
ShelleyBasedEra era
ShelleyBasedEraMary -> do
TxIns BuildTx era -> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns TxIns BuildTx era
txIns
[TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn)
-> TxIns BuildTx era -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst TxIns BuildTx era
txIns)
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts
TxMetadataInEra era -> Either TxBodyError ()
forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata
ShelleyBasedEra era
ShelleyBasedEraAlonzo -> do
TxIns BuildTx era -> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns TxIns BuildTx era
txIns
[TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn)
-> TxIns BuildTx era -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst TxIns BuildTx era
txIns)
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts
TxMetadataInEra era -> Either TxBodyError ()
forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata
TxInsCollateral era -> Set Language -> Either TxBodyError ()
forall era.
TxInsCollateral era -> Set Language -> Either TxBodyError ()
validateTxInsCollateral TxInsCollateral era
txInsCollateral Set Language
languages
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
forall era.
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
validateProtocolParameters BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams Set Language
languages
ShelleyBasedEra era
ShelleyBasedEraBabbage -> do
TxIns BuildTx era -> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns TxIns BuildTx era
txIns
[TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn)
-> TxIns BuildTx era -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst TxIns BuildTx era
txIns)
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts
TxMetadataInEra era -> Either TxBodyError ()
forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata
TxInsCollateral era -> Set Language -> Either TxBodyError ()
forall era.
TxInsCollateral era -> Set Language -> Either TxBodyError ()
validateTxInsCollateral TxInsCollateral era
txInsCollateral Set Language
languages
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
forall era.
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
validateProtocolParameters BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams Set Language
languages
ShelleyBasedEra era
ShelleyBasedEraConway -> do
TxIns BuildTx era -> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns TxIns BuildTx era
txIns
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts
TxMetadataInEra era -> Either TxBodyError ()
forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata
TxInsCollateral era -> Set Language -> Either TxBodyError ()
forall era.
TxInsCollateral era -> Set Language -> Either TxBodyError ()
validateTxInsCollateral TxInsCollateral era
txInsCollateral Set Language
languages
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
forall era.
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
validateProtocolParameters BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams Set Language
languages
validateMetadata :: TxMetadataInEra era -> Either TxBodyError ()
validateMetadata :: forall era. TxMetadataInEra era -> Either TxBodyError ()
validateMetadata TxMetadataInEra era
txMetadata =
case TxMetadataInEra era
txMetadata of
TxMetadataInEra era
TxMetadataNone -> () -> Either TxBodyError ()
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
TxMetadataInEra ShelleyBasedEra era
_ TxMetadata
m -> ([(Word64, TxMetadataRangeError)] -> TxBodyError)
-> Either [(Word64, TxMetadataRangeError)] ()
-> Either TxBodyError ()
forall a b c. (a -> b) -> Either a c -> Either b c
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
first [(Word64, TxMetadataRangeError)] -> TxBodyError
TxBodyMetadataError (TxMetadata -> Either [(Word64, TxMetadataRangeError)] ()
validateTxMetadata TxMetadata
m)
validateProtocolParameters
:: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Plutus.Language
-> Either TxBodyError ()
validateProtocolParameters :: forall era.
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Set Language -> Either TxBodyError ()
validateProtocolParameters BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams Set Language
languages =
case BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams of
BuildTxWith Maybe (LedgerProtocolParameters era)
Nothing
| Bool -> Bool
not (Set Language -> Bool
forall a. Set a -> Bool
Set.null Set Language
languages) ->
TxBodyError -> Either TxBodyError ()
forall a b. a -> Either a b
Left TxBodyError
TxBodyMissingProtocolParams
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
_ -> () -> Either TxBodyError ()
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
validateTxIns :: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))] -> Either TxBodyError ()
validateTxIns :: forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
validateTxIns [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
txIns =
[Either TxBodyError ()] -> Either TxBodyError ()
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
[ [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
forall a. [(TxIn, a)] -> Either TxBodyError ()
inputIndexDoesNotExceedMax [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
txIns
, [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
txBodyContentHasTxIns [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
txIns
]
validateTxInsCollateral
:: TxInsCollateral era -> Set Plutus.Language -> Either TxBodyError ()
validateTxInsCollateral :: forall era.
TxInsCollateral era -> Set Language -> Either TxBodyError ()
validateTxInsCollateral TxInsCollateral era
txInsCollateral Set Language
languages =
case TxInsCollateral era
txInsCollateral of
TxInsCollateral era
TxInsCollateralNone ->
Bool -> Either TxBodyError () -> Either TxBodyError ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
unless (Set Language -> Bool
forall a. Set a -> Bool
Set.null Set Language
languages) (TxBodyError -> Either TxBodyError ()
forall a b. a -> Either a b
Left TxBodyError
TxBodyEmptyTxInsCollateral)
TxInsCollateral AlonzoEraOnwards era
_ [TxIn]
collateralTxIns ->
[TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow [TxIn]
collateralTxIns
validateTxOuts :: ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts :: forall era.
ShelleyBasedEra era -> [TxOut CtxTx era] -> Either TxBodyError ()
validateTxOuts ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts = do
let era :: CardanoEra era
era = ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe
CardanoEra era
-> (CardanoEraConstraints era => Either TxBodyError ())
-> Either TxBodyError ()
forall era a.
CardanoEra era -> (CardanoEraConstraints era => a) -> a
cardanoEraConstraints CardanoEra era
era ((CardanoEraConstraints era => Either TxBodyError ())
-> Either TxBodyError ())
-> (CardanoEraConstraints era => Either TxBodyError ())
-> Either TxBodyError ()
forall a b. (a -> b) -> a -> b
$
[Either TxBodyError ()] -> Either TxBodyError ()
forall (t :: * -> *) (m :: * -> *) a.
(Foldable t, Monad m) =>
t (m a) -> m ()
sequence_
[ do
CardanoEra era -> Value -> TxOut CtxTx era -> Either TxBodyError ()
forall era.
CardanoEra era -> Value -> TxOut CtxTx era -> Either TxBodyError ()
positiveOutput CardanoEra era
era (TxOutValue era -> Value
forall era. TxOutValue era -> Value
txOutValueToValue TxOutValue era
v) TxOut CtxTx era
txout
CardanoEra era -> Value -> TxOut CtxTx era -> Either TxBodyError ()
forall era.
CardanoEra era -> Value -> TxOut CtxTx era -> Either TxBodyError ()
outputDoesNotExceedMax CardanoEra era
era (TxOutValue era -> Value
forall era. TxOutValue era -> Value
txOutValueToValue TxOutValue era
v) TxOut CtxTx era
txout
| txout :: TxOut CtxTx era
txout@(TxOut AddressInEra era
_ TxOutValue era
v TxOutDatum CtxTx era
_ ReferenceScript era
_) <- [TxOut CtxTx era]
txOuts
]
inputIndexDoesNotExceedMax :: [(TxIn, a)] -> Either TxBodyError ()
inputIndexDoesNotExceedMax :: forall a. [(TxIn, a)] -> Either TxBodyError ()
inputIndexDoesNotExceedMax [(TxIn, a)]
txIns =
[(TxIn, a)]
-> ((TxIn, a) -> Either TxBodyError ()) -> Either TxBodyError ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ [(TxIn, a)]
txIns (((TxIn, a) -> Either TxBodyError ()) -> Either TxBodyError ())
-> ((TxIn, a) -> Either TxBodyError ()) -> Either TxBodyError ()
forall a b. (a -> b) -> a -> b
$ \(txin :: TxIn
txin@(TxIn TxId
_ (TxIx Word
txix)), a
_) ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Word -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
txix Word -> Word -> Bool
forall a. Ord a => a -> a -> Bool
<= Word
maxShelleyTxInIx) Maybe () -> TxBodyError -> Either TxBodyError ()
forall a e. Maybe a -> e -> Either e a
?! TxIn -> TxBodyError
TxBodyInIxOverflow TxIn
txin
outputDoesNotExceedMax
:: ()
=> CardanoEra era
-> Value
-> TxOut CtxTx era
-> Either TxBodyError ()
outputDoesNotExceedMax :: forall era.
CardanoEra era -> Value -> TxOut CtxTx era -> Either TxBodyError ()
outputDoesNotExceedMax CardanoEra era
era Value
v TxOut CtxTx era
txout =
case [Quantity
q | (AssetId
_, Quantity
q) <- Value -> [Item Value]
forall l. IsList l => l -> [Item l]
toList Value
v, Quantity
q Quantity -> Quantity -> Bool
forall a. Ord a => a -> a -> Bool
> Quantity
maxTxOut] of
[] -> () -> Either TxBodyError ()
forall a b. b -> Either a b
Right ()
Quantity
q : [Quantity]
_ -> TxBodyError -> Either TxBodyError ()
forall a b. a -> Either a b
Left (Quantity -> TxOutInAnyEra -> TxBodyError
TxBodyOutputOverflow Quantity
q (CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
forall era. CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
txOutInAnyEra CardanoEra era
era TxOut CtxTx era
txout))
positiveOutput
:: ()
=> CardanoEra era
-> Value
-> TxOut CtxTx era
-> Either TxBodyError ()
positiveOutput :: forall era.
CardanoEra era -> Value -> TxOut CtxTx era -> Either TxBodyError ()
positiveOutput CardanoEra era
era Value
v TxOut CtxTx era
txout =
case [Quantity
q | (AssetId
_, Quantity
q) <- Value -> [Item Value]
forall l. IsList l => l -> [Item l]
toList Value
v, Quantity
q Quantity -> Quantity -> Bool
forall a. Ord a => a -> a -> Bool
< Quantity
0] of
[] -> () -> Either TxBodyError ()
forall a b. b -> Either a b
Right ()
Quantity
q : [Quantity]
_ -> TxBodyError -> Either TxBodyError ()
forall a b. a -> Either a b
Left (Quantity -> TxOutInAnyEra -> TxBodyError
TxBodyOutputNegative Quantity
q (CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
forall era. CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
txOutInAnyEra CardanoEra era
era TxOut CtxTx era
txout))
txBodyContentHasTxIns :: TxIns BuildTx era -> Either TxBodyError ()
txBodyContentHasTxIns :: forall era.
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> Either TxBodyError ()
txBodyContentHasTxIns TxIns BuildTx era
txIns = Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (TxIns BuildTx era -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null TxIns BuildTx era
txIns)) Maybe () -> TxBodyError -> Either TxBodyError ()
forall a e. Maybe a -> e -> Either e a
?! TxBodyError
TxBodyEmptyTxIns
maxShelleyTxInIx :: Word
maxShelleyTxInIx :: Word
maxShelleyTxInIx = Word16 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> Word) -> Word16 -> Word
forall a b. (a -> b) -> a -> b
$ forall a. Bounded a => a
maxBound @Word16
maxTxOut :: Quantity
maxTxOut :: Quantity
maxTxOut = Word64 -> Quantity
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64
forall a. Bounded a => a
maxBound :: Word64)
{-# DEPRECATED createAndValidateTransactionBody "Use createTransactionBody instead" #-}
createAndValidateTransactionBody
:: ()
=> ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> Either TxBodyError (TxBody era)
createAndValidateTransactionBody :: forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
createAndValidateTransactionBody = ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
makeShelleyTransactionBody
pattern TxBody :: TxBodyContent ViewTx era -> TxBody era
pattern $mTxBody :: forall {r} {era}.
TxBody era -> (TxBodyContent ViewTx era -> r) -> ((# #) -> r) -> r
TxBody txbodycontent <- (getTxBodyContent -> txbodycontent)
{-# COMPLETE TxBody #-}
getTxBodyContent :: TxBody era -> TxBodyContent ViewTx era
getTxBodyContent :: forall era. TxBody era -> TxBodyContent ViewTx era
getTxBodyContent = \case
ShelleyTxBody ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body [Script (ShelleyLedgerEra era)]
_scripts TxBodyScriptData era
scriptdata Maybe (TxAuxData (ShelleyLedgerEra era))
mAux TxScriptValidity era
scriptValidity ->
ShelleyBasedEra era
-> TxScriptValidity era
-> TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBodyContent ViewTx era
forall era.
ShelleyBasedEra era
-> TxScriptValidity era
-> TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBodyContent ViewTx era
fromLedgerTxBody ShelleyBasedEra era
sbe TxScriptValidity era
scriptValidity TxBody (ShelleyLedgerEra era)
body TxBodyScriptData era
scriptdata Maybe (TxAuxData (ShelleyLedgerEra era))
mAux
fromLedgerTxBody
:: ShelleyBasedEra era
-> TxScriptValidity era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> Maybe (L.TxAuxData (ShelleyLedgerEra era))
-> TxBodyContent ViewTx era
fromLedgerTxBody :: forall era.
ShelleyBasedEra era
-> TxScriptValidity era
-> TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBodyContent ViewTx era
fromLedgerTxBody ShelleyBasedEra era
sbe TxScriptValidity era
scriptValidity TxBody (ShelleyLedgerEra era)
body TxBodyScriptData era
scriptdata Maybe (TxAuxData (ShelleyLedgerEra era))
mAux =
TxBodyContent
{ txIns :: TxIns ViewTx era
txIns = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxIns ViewTx era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [(TxIn, BuildTxWith ViewTx (Witness WitCtxTxIn era))]
fromLedgerTxIns ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txInsCollateral :: TxInsCollateral era
txInsCollateral = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxInsCollateral era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxInsCollateral era
fromLedgerTxInsCollateral ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txInsReference :: TxInsReference era
txInsReference = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxInsReference era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxInsReference era
fromLedgerTxInsReference ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txOuts :: [TxOut CtxTx era]
txOuts = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> [TxOut CtxTx era]
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> [TxOut CtxTx era]
fromLedgerTxOuts ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body TxBodyScriptData era
scriptdata
, txTotalCollateral :: TxTotalCollateral era
txTotalCollateral = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxTotalCollateral era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxTotalCollateral era
fromLedgerTxTotalCollateral ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txReturnCollateral :: TxReturnCollateral CtxTx era
txReturnCollateral = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxReturnCollateral CtxTx era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxReturnCollateral CtxTx era
fromLedgerTxReturnCollateral ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txFee :: TxFee era
txFee = ShelleyBasedEra era -> TxBody (ShelleyLedgerEra era) -> TxFee era
forall era.
ShelleyBasedEra era -> TxBody (ShelleyLedgerEra era) -> TxFee era
fromLedgerTxFee ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound = ShelleyBasedEra era -> TxBody era -> TxValidityLowerBound era
forall era.
ShelleyBasedEra era -> TxBody era -> TxValidityLowerBound era
fromLedgerTxValidityLowerBound ShelleyBasedEra era
sbe (TxBody (ShelleyLedgerEra era) -> TxBody era
forall era. TxBody (ShelleyLedgerEra era) -> TxBody era
A.TxBody TxBody (ShelleyLedgerEra era)
body)
, txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound = ShelleyBasedEra era -> TxBody era -> TxValidityUpperBound era
forall era.
ShelleyBasedEra era -> TxBody era -> TxValidityUpperBound era
fromLedgerTxValidityUpperBound ShelleyBasedEra era
sbe (TxBody (ShelleyLedgerEra era) -> TxBody era
forall era. TxBody (ShelleyLedgerEra era) -> TxBody era
A.TxBody TxBody (ShelleyLedgerEra era)
body)
, txWithdrawals :: TxWithdrawals ViewTx era
txWithdrawals = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxWithdrawals ViewTx era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxWithdrawals ViewTx era
fromLedgerTxWithdrawals ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txCertificates :: TxCertificates ViewTx era
txCertificates = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxCertificates ViewTx era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxCertificates ViewTx era
fromLedgerTxCertificates ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txUpdateProposal :: TxUpdateProposal era
txUpdateProposal = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxUpdateProposal era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxUpdateProposal era
maybeFromLedgerTxUpdateProposal ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txMintValue :: TxMintValue ViewTx era
txMintValue = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxMintValue ViewTx era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxMintValue ViewTx era
fromLedgerTxMintValue ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxExtraKeyWitnesses era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxExtraKeyWitnesses era
fromLedgerTxExtraKeyWitnesses ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txProtocolParams :: BuildTxWith ViewTx (Maybe (LedgerProtocolParameters era))
txProtocolParams = BuildTxWith ViewTx (Maybe (LedgerProtocolParameters era))
forall a. BuildTxWith ViewTx a
ViewTx
, TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts
, txScriptValidity :: TxScriptValidity era
txScriptValidity = TxScriptValidity era
scriptValidity
, txProposalProcedures :: Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
txProposalProcedures = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
fromLedgerProposalProcedures ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txVotingProcedures :: Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
txVotingProcedures = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
fromLedgerVotingProcedures ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txCurrentTreasuryValue :: Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
fromLedgerCurrentTreasuryValue ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
, txTreasuryDonation :: Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation = ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era Coin)
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era Coin)
fromLedgerTreasuryDonation ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body
}
where
(TxMetadataInEra era
txMetadata, TxAuxScripts era
txAuxScripts) = ShelleyBasedEra era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> (TxMetadataInEra era, TxAuxScripts era)
forall era.
ShelleyBasedEra era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> (TxMetadataInEra era, TxAuxScripts era)
fromLedgerTxAuxiliaryData ShelleyBasedEra era
sbe Maybe (TxAuxData (ShelleyLedgerEra era))
mAux
fromLedgerProposalProcedures
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
fromLedgerProposalProcedures :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
fromLedgerProposalProcedures ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
ShelleyBasedEra era
-> (ConwayEraOnwards era
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
forall (eon :: * -> *) era a.
Eon eon =>
ShelleyBasedEra era -> (eon era -> a) -> Maybe a
forShelleyBasedEraInEonMaybe ShelleyBasedEra era
sbe ((ConwayEraOnwards era
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era)))
-> (ConwayEraOnwards era
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era)
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era)
forall a b. (a -> b) -> a -> b
$
ConwayEraOnwards era
-> TxProposalProcedures ViewTx era
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era)
forall (eon :: * -> *) era a. eon era -> a -> Featured eon era a
Featured ConwayEraOnwards era
w (TxProposalProcedures ViewTx era
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era))
-> TxProposalProcedures ViewTx era
-> Featured ConwayEraOnwards era (TxProposalProcedures ViewTx era)
forall a b. (a -> b) -> a -> b
$
OSet (ProposalProcedure (ShelleyLedgerEra era))
-> BuildTxWith
ViewTx
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> TxProposalProcedures ViewTx era
forall era build.
EraPParams (ShelleyLedgerEra era) =>
OSet (ProposalProcedure (ShelleyLedgerEra era))
-> BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> TxProposalProcedures build era
TxProposalProcedures
(TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(OSet (ProposalProcedure (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(OSet (ProposalProcedure (ShelleyLedgerEra era)))
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall s a. s -> Getting a s a -> a
^. Getting
(OSet (ProposalProcedure (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(OSet (ProposalProcedure (ShelleyLedgerEra era)))
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (OSet (ProposalProcedure era))
Lens'
(TxBody (ShelleyLedgerEra era))
(OSet (ProposalProcedure (ShelleyLedgerEra era)))
L.proposalProceduresTxBodyL)
BuildTxWith
ViewTx
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
forall a. BuildTxWith ViewTx a
ViewTx
fromLedgerVotingProcedures
:: ()
=> ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
fromLedgerVotingProcedures :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
fromLedgerVotingProcedures ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
ShelleyBasedEra era
-> (ConwayEraOnwards era
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
forall (eon :: * -> *) era a.
Eon eon =>
ShelleyBasedEra era -> (eon era -> a) -> Maybe a
forShelleyBasedEraInEonMaybe ShelleyBasedEra era
sbe ((ConwayEraOnwards era
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era)))
-> (ConwayEraOnwards era
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era)
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era)
forall a b. (a -> b) -> a -> b
$
ConwayEraOnwards era
-> TxVotingProcedures ViewTx era
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era)
forall (eon :: * -> *) era a. eon era -> a -> Featured eon era a
Featured ConwayEraOnwards era
w (TxVotingProcedures ViewTx era
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era))
-> TxVotingProcedures ViewTx era
-> Featured ConwayEraOnwards era (TxVotingProcedures ViewTx era)
forall a b. (a -> b) -> a -> b
$
VotingProcedures (ShelleyLedgerEra era)
-> BuildTxWith
ViewTx
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
-> TxVotingProcedures ViewTx era
forall era build.
VotingProcedures (ShelleyLedgerEra era)
-> BuildTxWith
build
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
-> TxVotingProcedures build era
TxVotingProcedures
(TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(VotingProcedures (ShelleyLedgerEra era))
(TxBody (ShelleyLedgerEra era))
(VotingProcedures (ShelleyLedgerEra era))
-> VotingProcedures (ShelleyLedgerEra era)
forall s a. s -> Getting a s a -> a
^. Getting
(VotingProcedures (ShelleyLedgerEra era))
(TxBody (ShelleyLedgerEra era))
(VotingProcedures (ShelleyLedgerEra era))
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (VotingProcedures era)
Lens'
(TxBody (ShelleyLedgerEra era))
(VotingProcedures (ShelleyLedgerEra era))
L.votingProceduresTxBodyL)
BuildTxWith
ViewTx
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
BuildTxWith
ViewTx (Map (Voter StandardCrypto) (ScriptWitness WitCtxStake era))
forall a. BuildTxWith ViewTx a
ViewTx
fromLedgerCurrentTreasuryValue
:: ()
=> ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
fromLedgerCurrentTreasuryValue :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
fromLedgerCurrentTreasuryValue ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body = CardanoEra era
-> (ConwayEraOnwards era
-> Featured ConwayEraOnwards era (Maybe Coin))
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
forall (eon :: * -> *) era a.
Eon eon =>
CardanoEra era -> (eon era -> a) -> Maybe a
forEraInEonMaybe (ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe) ((ConwayEraOnwards era
-> Featured ConwayEraOnwards era (Maybe Coin))
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin)))
-> (ConwayEraOnwards era
-> Featured ConwayEraOnwards era (Maybe Coin))
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
ceo ->
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (Maybe Coin))
-> Featured ConwayEraOnwards era (Maybe Coin)
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
ceo ((ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (Maybe Coin))
-> Featured ConwayEraOnwards era (Maybe Coin))
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era (Maybe Coin))
-> Featured ConwayEraOnwards era (Maybe Coin)
forall a b. (a -> b) -> a -> b
$
ConwayEraOnwards era
-> Maybe Coin -> Featured ConwayEraOnwards era (Maybe Coin)
forall (eon :: * -> *) era a. eon era -> a -> Featured eon era a
Featured ConwayEraOnwards era
ceo (Maybe Coin -> Featured ConwayEraOnwards era (Maybe Coin))
-> (StrictMaybe Coin -> Maybe Coin)
-> StrictMaybe Coin
-> Featured ConwayEraOnwards era (Maybe Coin)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. StrictMaybe Coin -> Maybe Coin
forall a. StrictMaybe a -> Maybe a
Ledger.strictMaybeToMaybe (StrictMaybe Coin -> Featured ConwayEraOnwards era (Maybe Coin))
-> StrictMaybe Coin -> Featured ConwayEraOnwards era (Maybe Coin)
forall a b. (a -> b) -> a -> b
$
TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(StrictMaybe Coin)
(TxBody (ShelleyLedgerEra era))
(StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
(StrictMaybe Coin)
(TxBody (ShelleyLedgerEra era))
(StrictMaybe Coin)
forall era.
ConwayEraTxBody era =>
Lens' (TxBody era) (StrictMaybe Coin)
Lens' (TxBody (ShelleyLedgerEra era)) (StrictMaybe Coin)
L.currentTreasuryValueTxBodyL
fromLedgerTreasuryDonation
:: ()
=> ShelleyBasedEra era
-> L.TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era Coin)
fromLedgerTreasuryDonation :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> Maybe (Featured ConwayEraOnwards era Coin)
fromLedgerTreasuryDonation ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
ShelleyBasedEra era
-> (ConwayEraOnwards era -> Featured ConwayEraOnwards era Coin)
-> Maybe (Featured ConwayEraOnwards era Coin)
forall (eon :: * -> *) era a.
Eon eon =>
ShelleyBasedEra era -> (eon era -> a) -> Maybe a
forShelleyBasedEraInEonMaybe ShelleyBasedEra era
sbe ((ConwayEraOnwards era -> Featured ConwayEraOnwards era Coin)
-> Maybe (Featured ConwayEraOnwards era Coin))
-> (ConwayEraOnwards era -> Featured ConwayEraOnwards era Coin)
-> Maybe (Featured ConwayEraOnwards era Coin)
forall a b. (a -> b) -> a -> b
$ \ConwayEraOnwards era
w ->
ConwayEraOnwards era
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era Coin)
-> Featured ConwayEraOnwards era Coin
forall era a.
ConwayEraOnwards era -> (ConwayEraOnwardsConstraints era => a) -> a
conwayEraOnwardsConstraints ConwayEraOnwards era
w ((ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era Coin)
-> Featured ConwayEraOnwards era Coin)
-> (ConwayEraOnwardsConstraints era =>
Featured ConwayEraOnwards era Coin)
-> Featured ConwayEraOnwards era Coin
forall a b. (a -> b) -> a -> b
$
ConwayEraOnwards era -> Coin -> Featured ConwayEraOnwards era Coin
forall (eon :: * -> *) era a. eon era -> a -> Featured eon era a
Featured ConwayEraOnwards era
w (TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting Coin (TxBody (ShelleyLedgerEra era)) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody (ShelleyLedgerEra era)) Coin
forall era. ConwayEraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody (ShelleyLedgerEra era)) Coin
L.treasuryDonationTxBodyL)
fromLedgerTxIns
:: forall era
. ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> [(TxIn, BuildTxWith ViewTx (Witness WitCtxTxIn era))]
fromLedgerTxIns :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [(TxIn, BuildTxWith ViewTx (Witness WitCtxTxIn era))]
fromLedgerTxIns ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
[ (TxIn StandardCrypto -> TxIn
fromShelleyTxIn TxIn StandardCrypto
input, BuildTxWith ViewTx (Witness WitCtxTxIn era)
forall a. BuildTxWith ViewTx a
ViewTx)
| TxIn StandardCrypto
input <- Set (TxIn StandardCrypto) -> [Item (Set (TxIn StandardCrypto))]
forall l. IsList l => l -> [Item l]
toList (ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> Set (TxIn StandardCrypto)
inputs_ ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body)
]
where
inputs_
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> Set (Ledger.TxIn StandardCrypto)
inputs_ :: ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> Set (TxIn StandardCrypto)
inputs_ ShelleyBasedEra era
ShelleyBasedEraShelley = Getting
(Set (TxIn StandardCrypto))
(ShelleyTxBody (ShelleyEra StandardCrypto))
(Set (TxIn StandardCrypto))
-> ShelleyTxBody (ShelleyEra StandardCrypto)
-> Set (TxIn StandardCrypto)
forall a s. Getting a s a -> s -> a
view (Set (TxIn (EraCrypto (ShelleyEra StandardCrypto)))
-> Const
(Set (TxIn StandardCrypto))
(Set (TxIn (EraCrypto (ShelleyEra StandardCrypto)))))
-> TxBody (ShelleyEra StandardCrypto)
-> Const
(Set (TxIn StandardCrypto)) (TxBody (ShelleyEra StandardCrypto))
Getting
(Set (TxIn StandardCrypto))
(ShelleyTxBody (ShelleyEra StandardCrypto))
(Set (TxIn StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (ShelleyEra StandardCrypto))
(Set (TxIn (EraCrypto (ShelleyEra StandardCrypto))))
L.inputsTxBodyL
inputs_ ShelleyBasedEra era
ShelleyBasedEraAllegra = Getting
(Set (TxIn StandardCrypto))
(AllegraTxBody (AllegraEra StandardCrypto))
(Set (TxIn StandardCrypto))
-> AllegraTxBody (AllegraEra StandardCrypto)
-> Set (TxIn StandardCrypto)
forall a s. Getting a s a -> s -> a
view (Set (TxIn (EraCrypto (AllegraEra StandardCrypto)))
-> Const
(Set (TxIn StandardCrypto))
(Set (TxIn (EraCrypto (AllegraEra StandardCrypto)))))
-> TxBody (AllegraEra StandardCrypto)
-> Const
(Set (TxIn StandardCrypto)) (TxBody (AllegraEra StandardCrypto))
Getting
(Set (TxIn StandardCrypto))
(AllegraTxBody (AllegraEra StandardCrypto))
(Set (TxIn StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (AllegraEra StandardCrypto))
(Set (TxIn (EraCrypto (AllegraEra StandardCrypto))))
L.inputsTxBodyL
inputs_ ShelleyBasedEra era
ShelleyBasedEraMary = Getting
(Set (TxIn StandardCrypto))
(MaryTxBody (MaryEra StandardCrypto))
(Set (TxIn StandardCrypto))
-> MaryTxBody (MaryEra StandardCrypto) -> Set (TxIn StandardCrypto)
forall a s. Getting a s a -> s -> a
view (Set (TxIn (EraCrypto (MaryEra StandardCrypto)))
-> Const
(Set (TxIn StandardCrypto))
(Set (TxIn (EraCrypto (MaryEra StandardCrypto)))))
-> TxBody (MaryEra StandardCrypto)
-> Const
(Set (TxIn StandardCrypto)) (TxBody (MaryEra StandardCrypto))
Getting
(Set (TxIn StandardCrypto))
(MaryTxBody (MaryEra StandardCrypto))
(Set (TxIn StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (MaryEra StandardCrypto))
(Set (TxIn (EraCrypto (MaryEra StandardCrypto))))
L.inputsTxBodyL
inputs_ ShelleyBasedEra era
ShelleyBasedEraAlonzo = Getting
(Set (TxIn StandardCrypto))
(AlonzoTxBody (AlonzoEra StandardCrypto))
(Set (TxIn StandardCrypto))
-> AlonzoTxBody (AlonzoEra StandardCrypto)
-> Set (TxIn StandardCrypto)
forall a s. Getting a s a -> s -> a
view (Set (TxIn (EraCrypto (AlonzoEra StandardCrypto)))
-> Const
(Set (TxIn StandardCrypto))
(Set (TxIn (EraCrypto (AlonzoEra StandardCrypto)))))
-> TxBody (AlonzoEra StandardCrypto)
-> Const
(Set (TxIn StandardCrypto)) (TxBody (AlonzoEra StandardCrypto))
Getting
(Set (TxIn StandardCrypto))
(AlonzoTxBody (AlonzoEra StandardCrypto))
(Set (TxIn StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (AlonzoEra StandardCrypto))
(Set (TxIn (EraCrypto (AlonzoEra StandardCrypto))))
L.inputsTxBodyL
inputs_ ShelleyBasedEra era
ShelleyBasedEraBabbage = Getting
(Set (TxIn StandardCrypto))
(BabbageTxBody StandardBabbage)
(Set (TxIn StandardCrypto))
-> BabbageTxBody StandardBabbage -> Set (TxIn StandardCrypto)
forall a s. Getting a s a -> s -> a
view (Set (TxIn (EraCrypto StandardBabbage))
-> Const
(Set (TxIn StandardCrypto))
(Set (TxIn (EraCrypto StandardBabbage))))
-> TxBody StandardBabbage
-> Const (Set (TxIn StandardCrypto)) (TxBody StandardBabbage)
Getting
(Set (TxIn StandardCrypto))
(BabbageTxBody StandardBabbage)
(Set (TxIn StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody StandardBabbage) (Set (TxIn (EraCrypto StandardBabbage)))
L.inputsTxBodyL
inputs_ ShelleyBasedEra era
ShelleyBasedEraConway = Getting
(Set (TxIn StandardCrypto))
(ConwayTxBody StandardConway)
(Set (TxIn StandardCrypto))
-> ConwayTxBody StandardConway -> Set (TxIn StandardCrypto)
forall a s. Getting a s a -> s -> a
view (Set (TxIn (EraCrypto StandardConway))
-> Const
(Set (TxIn StandardCrypto))
(Set (TxIn (EraCrypto StandardConway))))
-> TxBody StandardConway
-> Const (Set (TxIn StandardCrypto)) (TxBody StandardConway)
Getting
(Set (TxIn StandardCrypto))
(ConwayTxBody StandardConway)
(Set (TxIn StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody StandardConway) (Set (TxIn (EraCrypto StandardConway)))
L.inputsTxBodyL
fromLedgerTxInsCollateral
:: forall era
. ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxInsCollateral era
fromLedgerTxInsCollateral :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxInsCollateral era
fromLedgerTxInsCollateral ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
(ShelleyToMaryEraConstraints era =>
ShelleyToMaryEra era -> TxInsCollateral era)
-> (AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era -> TxInsCollateral era)
-> ShelleyBasedEra era
-> TxInsCollateral era
forall era a.
(ShelleyToMaryEraConstraints era => ShelleyToMaryEra era -> a)
-> (AlonzoEraOnwardsConstraints era => AlonzoEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToMaryOrAlonzoEraOnwards
(TxInsCollateral era -> ShelleyToMaryEra era -> TxInsCollateral era
forall a b. a -> b -> a
const TxInsCollateral era
forall era. TxInsCollateral era
TxInsCollateralNone)
(\AlonzoEraOnwards era
w -> AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
forall era. AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
TxInsCollateral AlonzoEraOnwards era
w ([TxIn] -> TxInsCollateral era) -> [TxIn] -> TxInsCollateral era
forall a b. (a -> b) -> a -> b
$ (TxIn StandardCrypto -> TxIn) -> [TxIn StandardCrypto] -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map TxIn StandardCrypto -> TxIn
fromShelleyTxIn ([TxIn StandardCrypto] -> [TxIn])
-> [TxIn StandardCrypto] -> [TxIn]
forall a b. (a -> b) -> a -> b
$ Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [Item (Set (TxIn (EraCrypto (ShelleyLedgerEra era))))]
forall l. IsList l => l -> [Item l]
toList (Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [Item (Set (TxIn (EraCrypto (ShelleyLedgerEra era))))])
-> Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [Item (Set (TxIn (EraCrypto (ShelleyLedgerEra era))))]
forall a b. (a -> b) -> a -> b
$ TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
-> Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
forall s a. s -> Getting a s a -> a
^. Getting
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
L.collateralInputsTxBodyL)
ShelleyBasedEra era
sbe
fromLedgerTxInsReference
:: ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxInsReference era
fromLedgerTxInsReference :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxInsReference era
fromLedgerTxInsReference ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
txBody =
(ShelleyToAlonzoEraConstraints era =>
ShelleyToAlonzoEra era -> TxInsReference era)
-> (BabbageEraOnwardsConstraints era =>
BabbageEraOnwards era -> TxInsReference era)
-> ShelleyBasedEra era
-> TxInsReference era
forall era a.
(ShelleyToAlonzoEraConstraints era => ShelleyToAlonzoEra era -> a)
-> (BabbageEraOnwardsConstraints era => BabbageEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToAlonzoOrBabbageEraOnwards
(TxInsReference era -> ShelleyToAlonzoEra era -> TxInsReference era
forall a b. a -> b -> a
const TxInsReference era
forall era. TxInsReference era
TxInsReferenceNone)
(\BabbageEraOnwards era
w -> BabbageEraOnwards era -> [TxIn] -> TxInsReference era
forall era. BabbageEraOnwards era -> [TxIn] -> TxInsReference era
TxInsReference BabbageEraOnwards era
w ([TxIn] -> TxInsReference era) -> [TxIn] -> TxInsReference era
forall a b. (a -> b) -> a -> b
$ (TxIn StandardCrypto -> TxIn) -> [TxIn StandardCrypto] -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map TxIn StandardCrypto -> TxIn
fromShelleyTxIn ([TxIn StandardCrypto] -> [TxIn])
-> (Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [TxIn StandardCrypto])
-> Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [TxIn]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [Item (Set (TxIn (EraCrypto (ShelleyLedgerEra era))))]
Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> [TxIn StandardCrypto]
forall l. IsList l => l -> [Item l]
toList (Set (TxIn (EraCrypto (ShelleyLedgerEra era))) -> [TxIn])
-> Set (TxIn (EraCrypto (ShelleyLedgerEra era))) -> [TxIn]
forall a b. (a -> b) -> a -> b
$ TxBody (ShelleyLedgerEra era)
txBody TxBody (ShelleyLedgerEra era)
-> Getting
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
-> Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
forall s a. s -> Getting a s a -> a
^. Getting
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
forall era.
BabbageEraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
L.referenceInputsTxBodyL)
ShelleyBasedEra era
sbe
fromLedgerTxOuts
:: forall era
. ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> [TxOut CtxTx era]
fromLedgerTxOuts :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> TxBodyScriptData era
-> [TxOut CtxTx era]
fromLedgerTxOuts ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body TxBodyScriptData era
scriptdata =
case ShelleyBasedEra era
sbe of
ShelleyBasedEra era
ShelleyBasedEraShelley ->
[ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut CtxTx era
forall era ctx.
ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut ctx era
fromShelleyTxOut ShelleyBasedEra era
sbe Item (StrictSeq (TxOut (ShelleyEra StandardCrypto)))
TxOut (ShelleyLedgerEra era)
txout | Item (StrictSeq (TxOut (ShelleyEra StandardCrypto)))
txout <- StrictSeq (TxOut (ShelleyEra StandardCrypto))
-> [Item (StrictSeq (TxOut (ShelleyEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList (TxBody (ShelleyLedgerEra era)
ShelleyTxBody (ShelleyEra StandardCrypto)
body ShelleyTxBody (ShelleyEra StandardCrypto)
-> Getting
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
(ShelleyTxBody (ShelleyEra StandardCrypto))
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
-> StrictSeq (TxOut (ShelleyEra StandardCrypto))
forall s a. s -> Getting a s a -> a
^. (StrictSeq (TxOut (ShelleyEra StandardCrypto))
-> Const
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
(StrictSeq (TxOut (ShelleyEra StandardCrypto))))
-> TxBody (ShelleyEra StandardCrypto)
-> Const
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
(TxBody (ShelleyEra StandardCrypto))
Getting
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
(ShelleyTxBody (ShelleyEra StandardCrypto))
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens'
(TxBody (ShelleyEra StandardCrypto))
(StrictSeq (TxOut (ShelleyEra StandardCrypto)))
L.outputsTxBodyL)]
ShelleyBasedEra era
ShelleyBasedEraAllegra ->
[ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut CtxTx era
forall era ctx.
ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut ctx era
fromShelleyTxOut ShelleyBasedEra era
sbe Item (StrictSeq (TxOut (AllegraEra StandardCrypto)))
TxOut (ShelleyLedgerEra era)
txout | Item (StrictSeq (TxOut (AllegraEra StandardCrypto)))
txout <- StrictSeq (TxOut (AllegraEra StandardCrypto))
-> [Item (StrictSeq (TxOut (AllegraEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList (AllegraTxBody (AllegraEra StandardCrypto)
TxBody (ShelleyLedgerEra era)
body AllegraTxBody (AllegraEra StandardCrypto)
-> Getting
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
(AllegraTxBody (AllegraEra StandardCrypto))
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
-> StrictSeq (TxOut (AllegraEra StandardCrypto))
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
(AllegraTxBody (AllegraEra StandardCrypto))
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
(StrictSeq (TxOut (AllegraEra StandardCrypto))
-> Const
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
(StrictSeq (TxOut (AllegraEra StandardCrypto))))
-> TxBody (AllegraEra StandardCrypto)
-> Const
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
(TxBody (AllegraEra StandardCrypto))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens'
(TxBody (AllegraEra StandardCrypto))
(StrictSeq (TxOut (AllegraEra StandardCrypto)))
L.outputsTxBodyL)]
ShelleyBasedEra era
ShelleyBasedEraMary ->
[ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut CtxTx era
forall era ctx.
ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut ctx era
fromShelleyTxOut ShelleyBasedEra era
sbe Item (StrictSeq (TxOut (MaryEra StandardCrypto)))
TxOut (ShelleyLedgerEra era)
txout | Item (StrictSeq (TxOut (MaryEra StandardCrypto)))
txout <- StrictSeq (TxOut (MaryEra StandardCrypto))
-> [Item (StrictSeq (TxOut (MaryEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList (TxBody (ShelleyLedgerEra era)
MaryTxBody (MaryEra StandardCrypto)
body MaryTxBody (MaryEra StandardCrypto)
-> Getting
(StrictSeq (TxOut (MaryEra StandardCrypto)))
(MaryTxBody (MaryEra StandardCrypto))
(StrictSeq (TxOut (MaryEra StandardCrypto)))
-> StrictSeq (TxOut (MaryEra StandardCrypto))
forall s a. s -> Getting a s a -> a
^. (StrictSeq (TxOut (MaryEra StandardCrypto))
-> Const
(StrictSeq (TxOut (MaryEra StandardCrypto)))
(StrictSeq (TxOut (MaryEra StandardCrypto))))
-> TxBody (MaryEra StandardCrypto)
-> Const
(StrictSeq (TxOut (MaryEra StandardCrypto)))
(TxBody (MaryEra StandardCrypto))
Getting
(StrictSeq (TxOut (MaryEra StandardCrypto)))
(MaryTxBody (MaryEra StandardCrypto))
(StrictSeq (TxOut (MaryEra StandardCrypto)))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens'
(TxBody (MaryEra StandardCrypto))
(StrictSeq (TxOut (MaryEra StandardCrypto)))
L.outputsTxBodyL)]
ShelleyBasedEra era
ShelleyBasedEraAlonzo ->
[ AlonzoEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (AlonzoEra StandardCrypto))
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
forall era ledgerera.
AlonzoEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromAlonzoTxOut
AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo
Map
(SafeHash StandardCrypto EraIndependentData)
(Data (AlonzoEra StandardCrypto))
Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums
Item (StrictSeq (TxOut (AlonzoEra StandardCrypto)))
TxOut (ShelleyLedgerEra era)
txout
| let txdatums :: Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums = TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
forall era.
TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
selectTxDatums TxBodyScriptData era
scriptdata
, Item (StrictSeq (TxOut (AlonzoEra StandardCrypto)))
txout <- StrictSeq (TxOut (AlonzoEra StandardCrypto))
-> [Item (StrictSeq (TxOut (AlonzoEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList (TxBody (ShelleyLedgerEra era)
AlonzoTxBody (AlonzoEra StandardCrypto)
body AlonzoTxBody (AlonzoEra StandardCrypto)
-> Getting
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
(AlonzoTxBody (AlonzoEra StandardCrypto))
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
-> StrictSeq (TxOut (AlonzoEra StandardCrypto))
forall s a. s -> Getting a s a -> a
^. (StrictSeq (TxOut (AlonzoEra StandardCrypto))
-> Const
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
(StrictSeq (TxOut (AlonzoEra StandardCrypto))))
-> TxBody (AlonzoEra StandardCrypto)
-> Const
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
(TxBody (AlonzoEra StandardCrypto))
Getting
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
(AlonzoTxBody (AlonzoEra StandardCrypto))
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens'
(TxBody (AlonzoEra StandardCrypto))
(StrictSeq (TxOut (AlonzoEra StandardCrypto)))
L.outputsTxBodyL)
]
ShelleyBasedEra era
ShelleyBasedEraBabbage ->
[ BabbageEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
forall era.
BabbageEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromBabbageTxOut
BabbageEraOnwards era
BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage
Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums
Item (StrictSeq (TxOut StandardBabbage))
TxOut (ShelleyLedgerEra era)
txouts
| let txdatums :: Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums = TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
forall era.
TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
selectTxDatums TxBodyScriptData era
scriptdata
, Item (StrictSeq (TxOut StandardBabbage))
txouts <- StrictSeq (TxOut StandardBabbage)
-> [Item (StrictSeq (TxOut StandardBabbage))]
forall l. IsList l => l -> [Item l]
toList (TxBody (ShelleyLedgerEra era)
BabbageTxBody StandardBabbage
body BabbageTxBody StandardBabbage
-> Getting
(StrictSeq (TxOut StandardBabbage))
(BabbageTxBody StandardBabbage)
(StrictSeq (TxOut StandardBabbage))
-> StrictSeq (TxOut StandardBabbage)
forall s a. s -> Getting a s a -> a
^. (StrictSeq (TxOut StandardBabbage)
-> Const
(StrictSeq (TxOut StandardBabbage))
(StrictSeq (TxOut StandardBabbage)))
-> TxBody StandardBabbage
-> Const
(StrictSeq (TxOut StandardBabbage)) (TxBody StandardBabbage)
Getting
(StrictSeq (TxOut StandardBabbage))
(BabbageTxBody StandardBabbage)
(StrictSeq (TxOut StandardBabbage))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens' (TxBody StandardBabbage) (StrictSeq (TxOut StandardBabbage))
L.outputsTxBodyL)
]
ShelleyBasedEra era
ShelleyBasedEraConway ->
[ BabbageEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
forall era.
BabbageEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromBabbageTxOut
BabbageEraOnwards era
BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway
Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums
Item (StrictSeq (TxOut StandardConway))
TxOut (ShelleyLedgerEra era)
txouts
| let txdatums :: Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums = TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
forall era.
TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
selectTxDatums TxBodyScriptData era
scriptdata
, Item (StrictSeq (TxOut StandardConway))
txouts <- StrictSeq (TxOut StandardConway)
-> [Item (StrictSeq (TxOut StandardConway))]
forall l. IsList l => l -> [Item l]
toList (TxBody (ShelleyLedgerEra era)
ConwayTxBody StandardConway
body ConwayTxBody StandardConway
-> Getting
(StrictSeq (TxOut StandardConway))
(ConwayTxBody StandardConway)
(StrictSeq (TxOut StandardConway))
-> StrictSeq (TxOut StandardConway)
forall s a. s -> Getting a s a -> a
^. (StrictSeq (TxOut StandardConway)
-> Const
(StrictSeq (TxOut StandardConway))
(StrictSeq (TxOut StandardConway)))
-> TxBody StandardConway
-> Const (StrictSeq (TxOut StandardConway)) (TxBody StandardConway)
Getting
(StrictSeq (TxOut StandardConway))
(ConwayTxBody StandardConway)
(StrictSeq (TxOut StandardConway))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens' (TxBody StandardConway) (StrictSeq (TxOut StandardConway))
L.outputsTxBodyL)
]
selectTxDatums
:: TxBodyScriptData era
-> Map (L.DataHash StandardCrypto) (L.Data (ShelleyLedgerEra era))
selectTxDatums :: forall era.
TxBodyScriptData era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
selectTxDatums TxBodyScriptData era
TxBodyNoScriptData = Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
forall k a. Map k a
Map.empty
selectTxDatums (TxBodyScriptData AlonzoEraOnwards era
_ (Alonzo.TxDats' Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era))
datums) Redeemers (ShelleyLedgerEra era)
_) = Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era))
Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
datums
fromAlonzoTxOut
:: forall era ledgerera
. AlonzoEraOnwards era
-> Map (L.DataHash StandardCrypto) (L.Data ledgerera)
-> L.TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromAlonzoTxOut :: forall era ledgerera.
AlonzoEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromAlonzoTxOut AlonzoEraOnwards era
w Map (SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
txdatums TxOut (ShelleyLedgerEra era)
txOut =
AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era => TxOut CtxTx era)
-> TxOut CtxTx era
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
w ((AlonzoEraOnwardsConstraints era => TxOut CtxTx era)
-> TxOut CtxTx era)
-> (AlonzoEraOnwardsConstraints era => TxOut CtxTx era)
-> TxOut CtxTx era
forall a b. (a -> b) -> a -> b
$
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
forall era.
ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
fromShelleyAddr ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra (TxOut (ShelleyLedgerEra era)
txOut TxOut (ShelleyLedgerEra era)
-> Getting
(Addr StandardCrypto)
(TxOut (ShelleyLedgerEra era))
(Addr StandardCrypto)
-> Addr StandardCrypto
forall s a. s -> Getting a s a -> a
^. (Addr (EraCrypto (ShelleyLedgerEra era))
-> Const
(Addr StandardCrypto) (Addr (EraCrypto (ShelleyLedgerEra era))))
-> TxOut (ShelleyLedgerEra era)
-> Const (Addr StandardCrypto) (TxOut (ShelleyLedgerEra era))
Getting
(Addr StandardCrypto)
(TxOut (ShelleyLedgerEra era))
(Addr StandardCrypto)
forall era.
EraTxOut era =>
Lens' (TxOut era) (Addr (EraCrypto era))
Lens'
(TxOut (ShelleyLedgerEra era))
(Addr (EraCrypto (ShelleyLedgerEra era)))
L.addrTxOutL))
(ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall era.
(Eq (Value (ShelleyLedgerEra era)),
Show (Value (ShelleyLedgerEra era))) =>
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
TxOutValueShelleyBased ShelleyBasedEra era
sbe (TxOut (ShelleyLedgerEra era)
txOut TxOut (ShelleyLedgerEra era)
-> Getting
(MaryValue StandardCrypto)
(TxOut (ShelleyLedgerEra era))
(MaryValue StandardCrypto)
-> MaryValue StandardCrypto
forall s a. s -> Getting a s a -> a
^. (Value (ShelleyLedgerEra era)
-> Const (MaryValue StandardCrypto) (Value (ShelleyLedgerEra era)))
-> TxOut (ShelleyLedgerEra era)
-> Const (MaryValue StandardCrypto) (TxOut (ShelleyLedgerEra era))
Getting
(MaryValue StandardCrypto)
(TxOut (ShelleyLedgerEra era))
(MaryValue StandardCrypto)
forall era. EraTxOut era => Lens' (TxOut era) (Value era)
Lens' (TxOut (ShelleyLedgerEra era)) (Value (ShelleyLedgerEra era))
L.valueTxOutL))
(AlonzoEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOutDatum CtxTx era
forall era ledgerera.
AlonzoEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOutDatum CtxTx era
fromAlonzoTxOutDatum AlonzoEraOnwards era
w Map (SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
txdatums (TxOut (ShelleyLedgerEra era)
txOut TxOut (ShelleyLedgerEra era)
-> Getting
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(TxOut (ShelleyLedgerEra era))
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall s a. s -> Getting a s a -> a
^. (StrictMaybe (DataHash (EraCrypto (ShelleyLedgerEra era)))
-> Const
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(StrictMaybe (DataHash (EraCrypto (ShelleyLedgerEra era)))))
-> TxOut (ShelleyLedgerEra era)
-> Const
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(TxOut (ShelleyLedgerEra era))
Getting
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
(TxOut (ShelleyLedgerEra era))
(StrictMaybe (SafeHash StandardCrypto EraIndependentData))
forall era.
AlonzoEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (DataHash (EraCrypto era)))
Lens'
(TxOut (ShelleyLedgerEra era))
(StrictMaybe (DataHash (EraCrypto (ShelleyLedgerEra era))))
L.dataHashTxOutL))
ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
where
ShelleyBasedEra era
sbe :: ShelleyBasedEra era = AlonzoEraOnwards era -> ShelleyBasedEra era
forall era. AlonzoEraOnwards era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert AlonzoEraOnwards era
w
fromAlonzoTxOutDatum
:: ()
=> AlonzoEraOnwards era
-> Map (L.DataHash StandardCrypto) (L.Data ledgerera)
-> StrictMaybe (L.DataHash StandardCrypto)
-> TxOutDatum CtxTx era
fromAlonzoTxOutDatum :: forall era ledgerera.
AlonzoEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOutDatum CtxTx era
fromAlonzoTxOutDatum AlonzoEraOnwards era
w Map (SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
txdatums = \case
StrictMaybe (SafeHash StandardCrypto EraIndependentData)
SNothing -> TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
SJust SafeHash StandardCrypto EraIndependentData
dh
| Just Data ledgerera
d <- SafeHash StandardCrypto EraIndependentData
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
-> Maybe (Data ledgerera)
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup SafeHash StandardCrypto EraIndependentData
dh Map (SafeHash StandardCrypto EraIndependentData) (Data ledgerera)
txdatums ->
AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
forall era.
AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
TxOutSupplementalDatum AlonzoEraOnwards era
w (Data ledgerera -> HashableScriptData
forall ledgerera. Data ledgerera -> HashableScriptData
fromAlonzoData Data ledgerera
d)
| Bool
otherwise -> AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum CtxTx era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash AlonzoEraOnwards era
w (SafeHash StandardCrypto EraIndependentData -> Hash ScriptData
ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh)
fromBabbageTxOut
:: forall era
. BabbageEraOnwards era
-> Map (L.DataHash StandardCrypto) (L.Data (ShelleyLedgerEra era))
-> L.TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromBabbageTxOut :: forall era.
BabbageEraOnwards era
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
-> TxOut (ShelleyLedgerEra era)
-> TxOut CtxTx era
fromBabbageTxOut BabbageEraOnwards era
w Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums TxOut (ShelleyLedgerEra era)
txout =
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => TxOut CtxTx era)
-> TxOut CtxTx era
forall era a.
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => a) -> a
babbageEraOnwardsConstraints BabbageEraOnwards era
w ((BabbageEraOnwardsConstraints era => TxOut CtxTx era)
-> TxOut CtxTx era)
-> (BabbageEraOnwardsConstraints era => TxOut CtxTx era)
-> TxOut CtxTx era
forall a b. (a -> b) -> a -> b
$
AddressInEra era
-> TxOutValue era
-> TxOutDatum CtxTx era
-> ReferenceScript era
-> TxOut CtxTx era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
TxOut
(ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
forall era.
ShelleyBasedEra era -> Addr StandardCrypto -> AddressInEra era
fromShelleyAddr ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra (TxOut (ShelleyLedgerEra era)
BabbageTxOut (ShelleyLedgerEra era)
txout BabbageTxOut (ShelleyLedgerEra era)
-> Getting
(Addr StandardCrypto)
(BabbageTxOut (ShelleyLedgerEra era))
(Addr StandardCrypto)
-> Addr StandardCrypto
forall s a. s -> Getting a s a -> a
^. (Addr (EraCrypto (ShelleyLedgerEra era))
-> Const
(Addr StandardCrypto) (Addr (EraCrypto (ShelleyLedgerEra era))))
-> TxOut (ShelleyLedgerEra era)
-> Const (Addr StandardCrypto) (TxOut (ShelleyLedgerEra era))
Getting
(Addr StandardCrypto)
(BabbageTxOut (ShelleyLedgerEra era))
(Addr StandardCrypto)
forall era.
EraTxOut era =>
Lens' (TxOut era) (Addr (EraCrypto era))
Lens'
(TxOut (ShelleyLedgerEra era))
(Addr (EraCrypto (ShelleyLedgerEra era)))
L.addrTxOutL))
(ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
forall era.
(Eq (Value (ShelleyLedgerEra era)),
Show (Value (ShelleyLedgerEra era))) =>
ShelleyBasedEra era
-> Value (ShelleyLedgerEra era) -> TxOutValue era
TxOutValueShelleyBased ShelleyBasedEra era
sbe (TxOut (ShelleyLedgerEra era)
BabbageTxOut (ShelleyLedgerEra era)
txout BabbageTxOut (ShelleyLedgerEra era)
-> Getting
(MaryValue StandardCrypto)
(BabbageTxOut (ShelleyLedgerEra era))
(MaryValue StandardCrypto)
-> MaryValue StandardCrypto
forall s a. s -> Getting a s a -> a
^. (Value (ShelleyLedgerEra era)
-> Const (MaryValue StandardCrypto) (Value (ShelleyLedgerEra era)))
-> TxOut (ShelleyLedgerEra era)
-> Const (MaryValue StandardCrypto) (TxOut (ShelleyLedgerEra era))
Getting
(MaryValue StandardCrypto)
(BabbageTxOut (ShelleyLedgerEra era))
(MaryValue StandardCrypto)
forall era. EraTxOut era => Lens' (TxOut era) (Value era)
Lens' (TxOut (ShelleyLedgerEra era)) (Value (ShelleyLedgerEra era))
L.valueTxOutL))
TxOutDatum CtxTx era
babbageTxOutDatum
( case TxOut (ShelleyLedgerEra era)
BabbageTxOut (ShelleyLedgerEra era)
txout BabbageTxOut (ShelleyLedgerEra era)
-> Getting
(StrictMaybe (Script (ShelleyLedgerEra era)))
(BabbageTxOut (ShelleyLedgerEra era))
(StrictMaybe (Script (ShelleyLedgerEra era)))
-> StrictMaybe (Script (ShelleyLedgerEra era))
forall s a. s -> Getting a s a -> a
^. (StrictMaybe (Script (ShelleyLedgerEra era))
-> Const
(StrictMaybe (Script (ShelleyLedgerEra era)))
(StrictMaybe (Script (ShelleyLedgerEra era))))
-> TxOut (ShelleyLedgerEra era)
-> Const
(StrictMaybe (Script (ShelleyLedgerEra era)))
(TxOut (ShelleyLedgerEra era))
Getting
(StrictMaybe (Script (ShelleyLedgerEra era)))
(BabbageTxOut (ShelleyLedgerEra era))
(StrictMaybe (Script (ShelleyLedgerEra era)))
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens'
(TxOut (ShelleyLedgerEra era))
(StrictMaybe (Script (ShelleyLedgerEra era)))
L.referenceScriptTxOutL of
StrictMaybe (Script (ShelleyLedgerEra era))
SNothing -> ReferenceScript era
forall era. ReferenceScript era
ReferenceScriptNone
SJust Script (ShelleyLedgerEra era)
rScript -> ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ReferenceScript era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ReferenceScript era
fromShelleyScriptToReferenceScript ShelleyBasedEra era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra Script (ShelleyLedgerEra era)
rScript
)
where
ShelleyBasedEra era
sbe :: ShelleyBasedEra era = BabbageEraOnwards era -> ShelleyBasedEra era
forall era. BabbageEraOnwards era -> ShelleyBasedEra era
forall a (f :: a -> *) (g :: a -> *) (era :: a).
Convert f g =>
f era -> g era
convert BabbageEraOnwards era
w
babbageTxOutDatum :: TxOutDatum CtxTx era
babbageTxOutDatum :: TxOutDatum CtxTx era
babbageTxOutDatum =
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => TxOutDatum CtxTx era)
-> TxOutDatum CtxTx era
forall era a.
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => a) -> a
babbageEraOnwardsConstraints BabbageEraOnwards era
w ((BabbageEraOnwardsConstraints era => TxOutDatum CtxTx era)
-> TxOutDatum CtxTx era)
-> (BabbageEraOnwardsConstraints era => TxOutDatum CtxTx era)
-> TxOutDatum CtxTx era
forall a b. (a -> b) -> a -> b
$
case TxOut (ShelleyLedgerEra era)
BabbageTxOut (ShelleyLedgerEra era)
txout BabbageTxOut (ShelleyLedgerEra era)
-> Getting
(Datum (ShelleyLedgerEra era))
(BabbageTxOut (ShelleyLedgerEra era))
(Datum (ShelleyLedgerEra era))
-> Datum (ShelleyLedgerEra era)
forall s a. s -> Getting a s a -> a
^. (Datum (ShelleyLedgerEra era)
-> Const
(Datum (ShelleyLedgerEra era)) (Datum (ShelleyLedgerEra era)))
-> TxOut (ShelleyLedgerEra era)
-> Const
(Datum (ShelleyLedgerEra era)) (TxOut (ShelleyLedgerEra era))
Getting
(Datum (ShelleyLedgerEra era))
(BabbageTxOut (ShelleyLedgerEra era))
(Datum (ShelleyLedgerEra era))
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut (ShelleyLedgerEra era)) (Datum (ShelleyLedgerEra era))
L.datumTxOutL of
Datum (ShelleyLedgerEra era)
L.NoDatum -> TxOutDatum CtxTx era
forall ctx era. TxOutDatum ctx era
TxOutDatumNone
L.DatumHash DataHash (EraCrypto (ShelleyLedgerEra era))
dh -> SafeHash StandardCrypto EraIndependentData -> TxOutDatum CtxTx era
resolveDatumInTx DataHash (EraCrypto (ShelleyLedgerEra era))
SafeHash StandardCrypto EraIndependentData
dh
L.Datum BinaryData (ShelleyLedgerEra era)
d -> BabbageEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
forall era ctx.
BabbageEraOnwards era -> HashableScriptData -> TxOutDatum ctx era
TxOutDatumInline BabbageEraOnwards era
w (HashableScriptData -> TxOutDatum CtxTx era)
-> HashableScriptData -> TxOutDatum CtxTx era
forall a b. (a -> b) -> a -> b
$ BabbageEraOnwards era
-> BinaryData (ShelleyLedgerEra era) -> HashableScriptData
forall ledgerera era.
Era ledgerera =>
BabbageEraOnwards era -> BinaryData ledgerera -> HashableScriptData
binaryDataToScriptData BabbageEraOnwards era
w BinaryData (ShelleyLedgerEra era)
d
resolveDatumInTx :: L.DataHash StandardCrypto -> TxOutDatum CtxTx era
resolveDatumInTx :: SafeHash StandardCrypto EraIndependentData -> TxOutDatum CtxTx era
resolveDatumInTx SafeHash StandardCrypto EraIndependentData
dh
| Just Data (ShelleyLedgerEra era)
d <- SafeHash StandardCrypto EraIndependentData
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
-> Maybe (Data (ShelleyLedgerEra era))
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup SafeHash StandardCrypto EraIndependentData
dh Map
(SafeHash StandardCrypto EraIndependentData)
(Data (ShelleyLedgerEra era))
txdatums =
AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
forall era.
AlonzoEraOnwards era -> HashableScriptData -> TxOutDatum CtxTx era
TxOutSupplementalDatum
(BabbageEraOnwards era -> AlonzoEraOnwards era
forall era. BabbageEraOnwards era -> AlonzoEraOnwards era
babbageEraOnwardsToAlonzoEraOnwards BabbageEraOnwards era
w)
(Data (ShelleyLedgerEra era) -> HashableScriptData
forall ledgerera. Data ledgerera -> HashableScriptData
fromAlonzoData Data (ShelleyLedgerEra era)
d)
| Bool
otherwise = AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum CtxTx era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
TxOutDatumHash (BabbageEraOnwards era -> AlonzoEraOnwards era
forall era. BabbageEraOnwards era -> AlonzoEraOnwards era
babbageEraOnwardsToAlonzoEraOnwards BabbageEraOnwards era
w) (SafeHash StandardCrypto EraIndependentData -> Hash ScriptData
ScriptDataHash SafeHash StandardCrypto EraIndependentData
dh)
fromLedgerTxTotalCollateral
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxTotalCollateral era
fromLedgerTxTotalCollateral :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxTotalCollateral era
fromLedgerTxTotalCollateral ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
txbody =
(ShelleyToAlonzoEraConstraints era =>
ShelleyToAlonzoEra era -> TxTotalCollateral era)
-> (BabbageEraOnwardsConstraints era =>
BabbageEraOnwards era -> TxTotalCollateral era)
-> ShelleyBasedEra era
-> TxTotalCollateral era
forall era a.
(ShelleyToAlonzoEraConstraints era => ShelleyToAlonzoEra era -> a)
-> (BabbageEraOnwardsConstraints era => BabbageEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToAlonzoOrBabbageEraOnwards
(TxTotalCollateral era
-> ShelleyToAlonzoEra era -> TxTotalCollateral era
forall a b. a -> b -> a
const TxTotalCollateral era
forall era. TxTotalCollateral era
TxTotalCollateralNone)
( \BabbageEraOnwards era
w ->
case TxBody (ShelleyLedgerEra era)
txbody TxBody (ShelleyLedgerEra era)
-> Getting
(StrictMaybe Coin)
(TxBody (ShelleyLedgerEra era))
(StrictMaybe Coin)
-> StrictMaybe Coin
forall s a. s -> Getting a s a -> a
^. Getting
(StrictMaybe Coin)
(TxBody (ShelleyLedgerEra era))
(StrictMaybe Coin)
forall era.
BabbageEraTxBody era =>
Lens' (TxBody era) (StrictMaybe Coin)
Lens' (TxBody (ShelleyLedgerEra era)) (StrictMaybe Coin)
L.totalCollateralTxBodyL of
StrictMaybe Coin
SNothing -> TxTotalCollateral era
forall era. TxTotalCollateral era
TxTotalCollateralNone
SJust Coin
totColl -> BabbageEraOnwards era -> Coin -> TxTotalCollateral era
forall era. BabbageEraOnwards era -> Coin -> TxTotalCollateral era
TxTotalCollateral BabbageEraOnwards era
w Coin
totColl
)
ShelleyBasedEra era
sbe
fromLedgerTxReturnCollateral
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxReturnCollateral CtxTx era
fromLedgerTxReturnCollateral :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxReturnCollateral CtxTx era
fromLedgerTxReturnCollateral ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
txbody =
(ShelleyToAlonzoEraConstraints era =>
ShelleyToAlonzoEra era -> TxReturnCollateral CtxTx era)
-> (BabbageEraOnwardsConstraints era =>
BabbageEraOnwards era -> TxReturnCollateral CtxTx era)
-> ShelleyBasedEra era
-> TxReturnCollateral CtxTx era
forall era a.
(ShelleyToAlonzoEraConstraints era => ShelleyToAlonzoEra era -> a)
-> (BabbageEraOnwardsConstraints era => BabbageEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToAlonzoOrBabbageEraOnwards
(TxReturnCollateral CtxTx era
-> ShelleyToAlonzoEra era -> TxReturnCollateral CtxTx era
forall a b. a -> b -> a
const TxReturnCollateral CtxTx era
forall ctx era. TxReturnCollateral ctx era
TxReturnCollateralNone)
( \BabbageEraOnwards era
w ->
case TxBody (ShelleyLedgerEra era)
txbody TxBody (ShelleyLedgerEra era)
-> Getting
(StrictMaybe (TxOut (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(StrictMaybe (TxOut (ShelleyLedgerEra era)))
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall s a. s -> Getting a s a -> a
^. Getting
(StrictMaybe (TxOut (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(StrictMaybe (TxOut (ShelleyLedgerEra era)))
forall era.
BabbageEraTxBody era =>
Lens' (TxBody era) (StrictMaybe (TxOut era))
Lens'
(TxBody (ShelleyLedgerEra era))
(StrictMaybe (TxOut (ShelleyLedgerEra era)))
L.collateralReturnTxBodyL of
StrictMaybe (TxOut (ShelleyLedgerEra era))
SNothing -> TxReturnCollateral CtxTx era
forall ctx era. TxReturnCollateral ctx era
TxReturnCollateralNone
SJust TxOut (ShelleyLedgerEra era)
collReturnOut -> BabbageEraOnwards era
-> TxOut CtxTx era -> TxReturnCollateral CtxTx era
forall era ctx.
BabbageEraOnwards era
-> TxOut ctx era -> TxReturnCollateral ctx era
TxReturnCollateral BabbageEraOnwards era
w (TxOut CtxTx era -> TxReturnCollateral CtxTx era)
-> TxOut CtxTx era -> TxReturnCollateral CtxTx era
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut CtxTx era
forall era ctx.
ShelleyBasedEra era
-> TxOut (ShelleyLedgerEra era) -> TxOut ctx era
fromShelleyTxOut ShelleyBasedEra era
sbe TxOut (ShelleyLedgerEra era)
collReturnOut
)
ShelleyBasedEra era
sbe
fromLedgerTxFee
:: ShelleyBasedEra era -> Ledger.TxBody (ShelleyLedgerEra era) -> TxFee era
fromLedgerTxFee :: forall era.
ShelleyBasedEra era -> TxBody (ShelleyLedgerEra era) -> TxFee era
fromLedgerTxFee ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxFee era) -> TxFee era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxFee era) -> TxFee era)
-> (ShelleyBasedEraConstraints era => TxFee era) -> TxFee era
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era -> Coin -> TxFee era
forall era. ShelleyBasedEra era -> Coin -> TxFee era
TxFeeExplicit ShelleyBasedEra era
sbe (Coin -> TxFee era) -> Coin -> TxFee era
forall a b. (a -> b) -> a -> b
$
TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting Coin (TxBody (ShelleyLedgerEra era)) Coin -> Coin
forall s a. s -> Getting a s a -> a
^. Getting Coin (TxBody (ShelleyLedgerEra era)) Coin
forall era. EraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody (ShelleyLedgerEra era)) Coin
L.feeTxBodyL
fromLedgerTxValidityLowerBound
:: ShelleyBasedEra era
-> A.TxBody era
-> TxValidityLowerBound era
fromLedgerTxValidityLowerBound :: forall era.
ShelleyBasedEra era -> TxBody era -> TxValidityLowerBound era
fromLedgerTxValidityLowerBound ShelleyBasedEra era
sbe TxBody era
body =
(ShelleyEraOnlyConstraints era =>
ShelleyEraOnly era -> TxValidityLowerBound era)
-> (AllegraEraOnwardsConstraints era =>
AllegraEraOnwards era -> TxValidityLowerBound era)
-> ShelleyBasedEra era
-> TxValidityLowerBound era
forall era a.
(ShelleyEraOnlyConstraints era => ShelleyEraOnly era -> a)
-> (AllegraEraOnwardsConstraints era => AllegraEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyEraOnlyOrAllegraEraOnwards
(TxValidityLowerBound era
-> ShelleyEraOnly era -> TxValidityLowerBound era
forall a b. a -> b -> a
const TxValidityLowerBound era
forall era. TxValidityLowerBound era
TxValidityNoLowerBound)
( \AllegraEraOnwards era
w ->
let mInvalidBefore :: Maybe SlotNo
mInvalidBefore = TxBody era
body TxBody era
-> Getting (Maybe SlotNo) (TxBody era) (Maybe SlotNo)
-> Maybe SlotNo
forall s a. s -> Getting a s a -> a
^. AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
w
in case Maybe SlotNo
mInvalidBefore of
Maybe SlotNo
Nothing -> TxValidityLowerBound era
forall era. TxValidityLowerBound era
TxValidityNoLowerBound
Just SlotNo
s -> AllegraEraOnwards era -> SlotNo -> TxValidityLowerBound era
forall era.
AllegraEraOnwards era -> SlotNo -> TxValidityLowerBound era
TxValidityLowerBound AllegraEraOnwards era
w SlotNo
s
)
ShelleyBasedEra era
sbe
fromLedgerTxValidityUpperBound
:: ShelleyBasedEra era
-> A.TxBody era
-> TxValidityUpperBound era
fromLedgerTxValidityUpperBound :: forall era.
ShelleyBasedEra era -> TxBody era -> TxValidityUpperBound era
fromLedgerTxValidityUpperBound ShelleyBasedEra era
sbe TxBody era
body =
ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
forall era.
ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
TxValidityUpperBound ShelleyBasedEra era
sbe (Maybe SlotNo -> TxValidityUpperBound era)
-> Maybe SlotNo -> TxValidityUpperBound era
forall a b. (a -> b) -> a -> b
$ TxBody era
body TxBody era
-> Getting (Maybe SlotNo) (TxBody era) (Maybe SlotNo)
-> Maybe SlotNo
forall s a. s -> Getting a s a -> a
^. ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe
fromLedgerAuxiliaryData
:: ShelleyBasedEra era
-> L.TxAuxData (ShelleyLedgerEra era)
-> (Map Word64 TxMetadataValue, [ScriptInEra era])
fromLedgerAuxiliaryData :: forall era.
ShelleyBasedEra era
-> TxAuxData (ShelleyLedgerEra era)
-> (Map Word64 TxMetadataValue, [ScriptInEra era])
fromLedgerAuxiliaryData ShelleyBasedEra era
ShelleyBasedEraShelley (L.ShelleyTxAuxData Map Word64 Metadatum
metadata) =
(Map Word64 Metadatum -> Map Word64 TxMetadataValue
fromShelleyMetadata Map Word64 Metadatum
metadata, [])
fromLedgerAuxiliaryData ShelleyBasedEra era
ShelleyBasedEraAllegra (L.AllegraTxAuxData Map Word64 Metadatum
ms StrictSeq (Timelock (AllegraEra StandardCrypto))
ss) =
( Map Word64 Metadatum -> Map Word64 TxMetadataValue
fromShelleyMetadata Map Word64 Metadatum
ms
, ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
fromShelleyBasedScript ShelleyBasedEra era
ShelleyBasedEra AllegraEra
ShelleyBasedEraAllegra (Timelock (AllegraEra StandardCrypto) -> ScriptInEra era)
-> [Timelock (AllegraEra StandardCrypto)] -> [ScriptInEra era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (Timelock (AllegraEra StandardCrypto))
-> [Item (StrictSeq (Timelock (AllegraEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList StrictSeq (Timelock (AllegraEra StandardCrypto))
ss
)
fromLedgerAuxiliaryData ShelleyBasedEra era
ShelleyBasedEraMary (L.AllegraTxAuxData Map Word64 Metadatum
ms StrictSeq (Timelock (MaryEra StandardCrypto))
ss) =
( Map Word64 Metadatum -> Map Word64 TxMetadataValue
fromShelleyMetadata Map Word64 Metadatum
ms
, ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
fromShelleyBasedScript ShelleyBasedEra era
ShelleyBasedEra MaryEra
ShelleyBasedEraMary (Timelock (MaryEra StandardCrypto) -> ScriptInEra era)
-> [Timelock (MaryEra StandardCrypto)] -> [ScriptInEra era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (Timelock (MaryEra StandardCrypto))
-> [Item (StrictSeq (Timelock (MaryEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList StrictSeq (Timelock (MaryEra StandardCrypto))
ss
)
fromLedgerAuxiliaryData ShelleyBasedEra era
ShelleyBasedEraAlonzo TxAuxData (ShelleyLedgerEra era)
txAuxData =
( Map Word64 Metadatum -> Map Word64 TxMetadataValue
fromShelleyMetadata (AlonzoTxAuxData (AlonzoEra StandardCrypto) -> Map Word64 Metadatum
forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Word64 Metadatum
L.atadMetadata TxAuxData (ShelleyLedgerEra era)
AlonzoTxAuxData (AlonzoEra StandardCrypto)
txAuxData)
, ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
fromShelleyBasedScript ShelleyBasedEra era
ShelleyBasedEra AlonzoEra
ShelleyBasedEraAlonzo
(AlonzoScript (AlonzoEra StandardCrypto) -> ScriptInEra era)
-> [AlonzoScript (AlonzoEra StandardCrypto)] -> [ScriptInEra era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (AlonzoScript (AlonzoEra StandardCrypto))
-> [Item (StrictSeq (AlonzoScript (AlonzoEra StandardCrypto)))]
forall l. IsList l => l -> [Item l]
toList (AlonzoTxAuxData (AlonzoEra StandardCrypto)
-> StrictSeq (AlonzoScript (AlonzoEra StandardCrypto))
forall era.
AlonzoEraScript era =>
AlonzoTxAuxData era -> StrictSeq (AlonzoScript era)
L.getAlonzoTxAuxDataScripts TxAuxData (ShelleyLedgerEra era)
AlonzoTxAuxData (AlonzoEra StandardCrypto)
txAuxData)
)
fromLedgerAuxiliaryData ShelleyBasedEra era
ShelleyBasedEraBabbage TxAuxData (ShelleyLedgerEra era)
txAuxData =
( Map Word64 Metadatum -> Map Word64 TxMetadataValue
fromShelleyMetadata (AlonzoTxAuxData StandardBabbage -> Map Word64 Metadatum
forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Word64 Metadatum
L.atadMetadata TxAuxData (ShelleyLedgerEra era)
AlonzoTxAuxData StandardBabbage
txAuxData)
, ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
fromShelleyBasedScript ShelleyBasedEra era
ShelleyBasedEra BabbageEra
ShelleyBasedEraBabbage
(AlonzoScript StandardBabbage -> ScriptInEra era)
-> [AlonzoScript StandardBabbage] -> [ScriptInEra era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (AlonzoScript StandardBabbage)
-> [Item (StrictSeq (AlonzoScript StandardBabbage))]
forall l. IsList l => l -> [Item l]
toList (AlonzoTxAuxData StandardBabbage
-> StrictSeq (AlonzoScript StandardBabbage)
forall era.
AlonzoEraScript era =>
AlonzoTxAuxData era -> StrictSeq (AlonzoScript era)
L.getAlonzoTxAuxDataScripts TxAuxData (ShelleyLedgerEra era)
AlonzoTxAuxData StandardBabbage
txAuxData)
)
fromLedgerAuxiliaryData ShelleyBasedEra era
ShelleyBasedEraConway TxAuxData (ShelleyLedgerEra era)
txAuxData =
( Map Word64 Metadatum -> Map Word64 TxMetadataValue
fromShelleyMetadata (AlonzoTxAuxData StandardConway -> Map Word64 Metadatum
forall era.
(HasCallStack, AlonzoEraScript era) =>
AlonzoTxAuxData era -> Map Word64 Metadatum
L.atadMetadata TxAuxData (ShelleyLedgerEra era)
AlonzoTxAuxData StandardConway
txAuxData)
, ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
forall era.
ShelleyBasedEra era
-> Script (ShelleyLedgerEra era) -> ScriptInEra era
fromShelleyBasedScript ShelleyBasedEra era
ShelleyBasedEra ConwayEra
ShelleyBasedEraConway
(AlonzoScript StandardConway -> ScriptInEra era)
-> [AlonzoScript StandardConway] -> [ScriptInEra era]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> StrictSeq (AlonzoScript StandardConway)
-> [Item (StrictSeq (AlonzoScript StandardConway))]
forall l. IsList l => l -> [Item l]
toList (AlonzoTxAuxData StandardConway
-> StrictSeq (AlonzoScript StandardConway)
forall era.
AlonzoEraScript era =>
AlonzoTxAuxData era -> StrictSeq (AlonzoScript era)
L.getAlonzoTxAuxDataScripts TxAuxData (ShelleyLedgerEra era)
AlonzoTxAuxData StandardConway
txAuxData)
)
fromLedgerTxAuxiliaryData
:: ShelleyBasedEra era
-> Maybe (L.TxAuxData (ShelleyLedgerEra era))
-> (TxMetadataInEra era, TxAuxScripts era)
fromLedgerTxAuxiliaryData :: forall era.
ShelleyBasedEra era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> (TxMetadataInEra era, TxAuxScripts era)
fromLedgerTxAuxiliaryData ShelleyBasedEra era
_ Maybe (TxAuxData (ShelleyLedgerEra era))
Nothing = (TxMetadataInEra era
forall era. TxMetadataInEra era
TxMetadataNone, TxAuxScripts era
forall era. TxAuxScripts era
TxAuxScriptsNone)
fromLedgerTxAuxiliaryData ShelleyBasedEra era
sbe (Just TxAuxData (ShelleyLedgerEra era)
auxData) =
(TxMetadataInEra era
metadata, TxAuxScripts era
auxdata)
where
metadata :: TxMetadataInEra era
metadata = if Map Word64 TxMetadataValue -> Bool
forall a. Map Word64 a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null Map Word64 TxMetadataValue
ms then TxMetadataInEra era
forall era. TxMetadataInEra era
TxMetadataNone else ShelleyBasedEra era -> TxMetadata -> TxMetadataInEra era
forall era.
ShelleyBasedEra era -> TxMetadata -> TxMetadataInEra era
TxMetadataInEra ShelleyBasedEra era
sbe (TxMetadata -> TxMetadataInEra era)
-> TxMetadata -> TxMetadataInEra era
forall a b. (a -> b) -> a -> b
$ Map Word64 TxMetadataValue -> TxMetadata
TxMetadata Map Word64 TxMetadataValue
ms
auxdata :: TxAuxScripts era
auxdata =
(ShelleyEraOnlyConstraints era =>
ShelleyEraOnly era -> TxAuxScripts era)
-> (AllegraEraOnwardsConstraints era =>
AllegraEraOnwards era -> TxAuxScripts era)
-> ShelleyBasedEra era
-> TxAuxScripts era
forall era a.
(ShelleyEraOnlyConstraints era => ShelleyEraOnly era -> a)
-> (AllegraEraOnwardsConstraints era => AllegraEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyEraOnlyOrAllegraEraOnwards
(TxAuxScripts era -> ShelleyEraOnly era -> TxAuxScripts era
forall a b. a -> b -> a
const TxAuxScripts era
forall era. TxAuxScripts era
TxAuxScriptsNone)
( \AllegraEraOnwards era
w ->
case [ScriptInEra era]
ss of
[] -> TxAuxScripts era
forall era. TxAuxScripts era
TxAuxScriptsNone
[ScriptInEra era]
_ -> AllegraEraOnwards era -> [ScriptInEra era] -> TxAuxScripts era
forall era.
AllegraEraOnwards era -> [ScriptInEra era] -> TxAuxScripts era
TxAuxScripts AllegraEraOnwards era
w [ScriptInEra era]
ss
)
ShelleyBasedEra era
sbe
(Map Word64 TxMetadataValue
ms, [ScriptInEra era]
ss) = ShelleyBasedEra era
-> TxAuxData (ShelleyLedgerEra era)
-> (Map Word64 TxMetadataValue, [ScriptInEra era])
forall era.
ShelleyBasedEra era
-> TxAuxData (ShelleyLedgerEra era)
-> (Map Word64 TxMetadataValue, [ScriptInEra era])
fromLedgerAuxiliaryData ShelleyBasedEra era
sbe TxAuxData (ShelleyLedgerEra era)
auxData
fromLedgerTxExtraKeyWitnesses
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxExtraKeyWitnesses era
ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
(ShelleyToMaryEraConstraints era =>
ShelleyToMaryEra era -> TxExtraKeyWitnesses era)
-> (AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era -> TxExtraKeyWitnesses era)
-> ShelleyBasedEra era
-> TxExtraKeyWitnesses era
forall era a.
(ShelleyToMaryEraConstraints era => ShelleyToMaryEra era -> a)
-> (AlonzoEraOnwardsConstraints era => AlonzoEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToMaryOrAlonzoEraOnwards
(TxExtraKeyWitnesses era
-> ShelleyToMaryEra era -> TxExtraKeyWitnesses era
forall a b. a -> b -> a
const TxExtraKeyWitnesses era
forall era. TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone)
( \AlonzoEraOnwards era
w ->
let keyhashes :: Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
keyhashes = TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
-> Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
forall s a. s -> Getting a s a -> a
^. Getting
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (KeyHash 'Witness (EraCrypto era)))
Lens'
(TxBody (ShelleyLedgerEra era))
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
L.reqSignerHashesTxBodyL
in if Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))) -> Bool
forall a. Set a -> Bool
Set.null Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
keyhashes
then TxExtraKeyWitnesses era
forall era. TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone
else
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
forall era.
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
TxExtraKeyWitnesses
AlonzoEraOnwards era
w
[ KeyHash 'Payment StandardCrypto -> Hash PaymentKey
PaymentKeyHash (KeyHash 'Witness StandardCrypto -> KeyHash 'Payment StandardCrypto
forall (r :: KeyRole) c (r' :: KeyRole).
KeyHash r c -> KeyHash r' c
forall (a :: KeyRole -> * -> *) (r :: KeyRole) c (r' :: KeyRole).
HasKeyRole a =>
a r c -> a r' c
Shelley.coerceKeyRole KeyHash 'Witness StandardCrypto
keyhash)
| KeyHash 'Witness StandardCrypto
keyhash <- Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
-> [Item
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))]
forall l. IsList l => l -> [Item l]
toList (Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
-> [Item
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))])
-> Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
-> [Item
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))]
forall a b. (a -> b) -> a -> b
$ TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
-> Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era)))
forall s a. s -> Getting a s a -> a
^. Getting
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
(TxBody (ShelleyLedgerEra era))
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
forall era.
AlonzoEraTxBody era =>
Lens' (TxBody era) (Set (KeyHash 'Witness (EraCrypto era)))
Lens'
(TxBody (ShelleyLedgerEra era))
(Set (KeyHash 'Witness (EraCrypto (ShelleyLedgerEra era))))
L.reqSignerHashesTxBodyL
]
)
ShelleyBasedEra era
sbe
fromLedgerTxWithdrawals
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxWithdrawals ViewTx era
fromLedgerTxWithdrawals :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxWithdrawals ViewTx era
fromLedgerTxWithdrawals ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxWithdrawals ViewTx era)
-> TxWithdrawals ViewTx era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxWithdrawals ViewTx era)
-> TxWithdrawals ViewTx era)
-> (ShelleyBasedEraConstraints era => TxWithdrawals ViewTx era)
-> TxWithdrawals ViewTx era
forall a b. (a -> b) -> a -> b
$
let withdrawals :: Withdrawals StandardCrypto
withdrawals = TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(Withdrawals StandardCrypto)
(TxBody (ShelleyLedgerEra era))
(Withdrawals StandardCrypto)
-> Withdrawals StandardCrypto
forall s a. s -> Getting a s a -> a
^. (Withdrawals (EraCrypto (ShelleyLedgerEra era))
-> Const
(Withdrawals StandardCrypto)
(Withdrawals (EraCrypto (ShelleyLedgerEra era))))
-> TxBody (ShelleyLedgerEra era)
-> Const
(Withdrawals StandardCrypto) (TxBody (ShelleyLedgerEra era))
Getting
(Withdrawals StandardCrypto)
(TxBody (ShelleyLedgerEra era))
(Withdrawals StandardCrypto)
forall era.
EraTxBody era =>
Lens' (TxBody era) (Withdrawals (EraCrypto era))
Lens'
(TxBody (ShelleyLedgerEra era))
(Withdrawals (EraCrypto (ShelleyLedgerEra era)))
L.withdrawalsTxBodyL
in if Map (RewardAccount StandardCrypto) Coin -> Bool
forall a. Map (RewardAccount StandardCrypto) a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (Withdrawals StandardCrypto
-> Map (RewardAccount StandardCrypto) Coin
forall c. Withdrawals c -> Map (RewardAccount c) Coin
L.unWithdrawals Withdrawals StandardCrypto
withdrawals)
then TxWithdrawals ViewTx era
forall build era. TxWithdrawals build era
TxWithdrawalsNone
else ShelleyBasedEra era
-> [(StakeAddress, Coin,
BuildTxWith ViewTx (Witness WitCtxStake era))]
-> TxWithdrawals ViewTx era
forall era build.
ShelleyBasedEra era
-> [(StakeAddress, Coin,
BuildTxWith build (Witness WitCtxStake era))]
-> TxWithdrawals build era
TxWithdrawals ShelleyBasedEra era
sbe ([(StakeAddress, Coin,
BuildTxWith ViewTx (Witness WitCtxStake era))]
-> TxWithdrawals ViewTx era)
-> [(StakeAddress, Coin,
BuildTxWith ViewTx (Witness WitCtxStake era))]
-> TxWithdrawals ViewTx era
forall a b. (a -> b) -> a -> b
$ Withdrawals StandardCrypto
-> [(StakeAddress, Coin,
BuildTxWith ViewTx (Witness WitCtxStake era))]
forall era.
Withdrawals StandardCrypto
-> [(StakeAddress, Coin,
BuildTxWith ViewTx (Witness WitCtxStake era))]
fromShelleyWithdrawal Withdrawals StandardCrypto
withdrawals
fromLedgerTxCertificates
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxCertificates ViewTx era
fromLedgerTxCertificates :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxCertificates ViewTx era
fromLedgerTxCertificates ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxCertificates ViewTx era)
-> TxCertificates ViewTx era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxCertificates ViewTx era)
-> TxCertificates ViewTx era)
-> (ShelleyBasedEraConstraints era => TxCertificates ViewTx era)
-> TxCertificates ViewTx era
forall a b. (a -> b) -> a -> b
$
let certificates :: StrictSeq (TxCert (ShelleyLedgerEra era))
certificates = TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(StrictSeq (TxCert (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(StrictSeq (TxCert (ShelleyLedgerEra era)))
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall s a. s -> Getting a s a -> a
^. Getting
(StrictSeq (TxCert (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxCert era))
Lens'
(TxBody (ShelleyLedgerEra era))
(StrictSeq (TxCert (ShelleyLedgerEra era)))
L.certsTxBodyL
in if StrictSeq (TxCert (ShelleyLedgerEra era)) -> Bool
forall a. StrictSeq a -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null StrictSeq (TxCert (ShelleyLedgerEra era))
certificates
then TxCertificates ViewTx era
forall build era. TxCertificates build era
TxCertificatesNone
else ShelleyBasedEra era
-> [Certificate era]
-> BuildTxWith ViewTx [(StakeCredential, Witness WitCtxStake era)]
-> TxCertificates ViewTx era
forall era build.
ShelleyBasedEra era
-> [Certificate era]
-> BuildTxWith build [(StakeCredential, Witness WitCtxStake era)]
-> TxCertificates build era
TxCertificates ShelleyBasedEra era
sbe ((TxCert (ShelleyLedgerEra era) -> Certificate era)
-> [TxCert (ShelleyLedgerEra era)] -> [Certificate era]
forall a b. (a -> b) -> [a] -> [b]
map (ShelleyBasedEra era
-> TxCert (ShelleyLedgerEra era) -> Certificate era
forall era.
ShelleyBasedEra era
-> TxCert (ShelleyLedgerEra era) -> Certificate era
fromShelleyCertificate ShelleyBasedEra era
sbe) ([TxCert (ShelleyLedgerEra era)] -> [Certificate era])
-> [TxCert (ShelleyLedgerEra era)] -> [Certificate era]
forall a b. (a -> b) -> a -> b
$ StrictSeq (TxCert (ShelleyLedgerEra era))
-> [Item (StrictSeq (TxCert (ShelleyLedgerEra era)))]
forall l. IsList l => l -> [Item l]
toList StrictSeq (TxCert (ShelleyLedgerEra era))
certificates) BuildTxWith ViewTx [(StakeCredential, Witness WitCtxStake era)]
forall a. BuildTxWith ViewTx a
ViewTx
maybeFromLedgerTxUpdateProposal
:: ()
=> ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxUpdateProposal era
maybeFromLedgerTxUpdateProposal :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxUpdateProposal era
maybeFromLedgerTxUpdateProposal ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body =
(ShelleyToBabbageEraConstraints era =>
ShelleyToBabbageEra era -> TxUpdateProposal era)
-> (ConwayEraOnwardsConstraints era =>
ConwayEraOnwards era -> TxUpdateProposal era)
-> ShelleyBasedEra era
-> TxUpdateProposal era
forall era a.
(ShelleyToBabbageEraConstraints era =>
ShelleyToBabbageEra era -> a)
-> (ConwayEraOnwardsConstraints era => ConwayEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToBabbageOrConwayEraOnwards
( \ShelleyToBabbageEra era
w ->
case TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(StrictMaybe (Update (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(StrictMaybe (Update (ShelleyLedgerEra era)))
-> StrictMaybe (Update (ShelleyLedgerEra era))
forall s a. s -> Getting a s a -> a
^. Getting
(StrictMaybe (Update (ShelleyLedgerEra era)))
(TxBody (ShelleyLedgerEra era))
(StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyEraTxBody era =>
Lens' (TxBody era) (StrictMaybe (Update era))
Lens'
(TxBody (ShelleyLedgerEra era))
(StrictMaybe (Update (ShelleyLedgerEra era)))
L.updateTxBodyL of
StrictMaybe (Update (ShelleyLedgerEra era))
SNothing -> TxUpdateProposal era
forall era. TxUpdateProposal era
TxUpdateProposalNone
SJust Update (ShelleyLedgerEra era)
p -> ShelleyToBabbageEra era -> UpdateProposal -> TxUpdateProposal era
forall era.
ShelleyToBabbageEra era -> UpdateProposal -> TxUpdateProposal era
TxUpdateProposal ShelleyToBabbageEra era
w (ShelleyBasedEra era
-> Update (ShelleyLedgerEra era) -> UpdateProposal
forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera,
EraCrypto ledgerera ~ StandardCrypto) =>
ShelleyBasedEra era -> Update ledgerera -> UpdateProposal
fromLedgerUpdate ShelleyBasedEra era
sbe Update (ShelleyLedgerEra era)
p)
)
(TxUpdateProposal era
-> ConwayEraOnwards era -> TxUpdateProposal era
forall a b. a -> b -> a
const TxUpdateProposal era
forall era. TxUpdateProposal era
TxUpdateProposalNone)
ShelleyBasedEra era
sbe
fromLedgerTxMintValue
:: ShelleyBasedEra era
-> Ledger.TxBody (ShelleyLedgerEra era)
-> TxMintValue ViewTx era
fromLedgerTxMintValue :: forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era) -> TxMintValue ViewTx era
fromLedgerTxMintValue ShelleyBasedEra era
sbe TxBody (ShelleyLedgerEra era)
body = CardanoEra era
-> TxMintValue ViewTx era
-> (MaryEraOnwards era -> TxMintValue ViewTx era)
-> TxMintValue ViewTx era
forall (eon :: * -> *) era a.
Eon eon =>
CardanoEra era -> a -> (eon era -> a) -> a
forEraInEon (ShelleyBasedEra era -> CardanoEra era
forall era. ShelleyBasedEra era -> CardanoEra era
forall (eon :: * -> *) era.
ToCardanoEra eon =>
eon era -> CardanoEra era
toCardanoEra ShelleyBasedEra era
sbe) TxMintValue ViewTx era
forall build era. TxMintValue build era
TxMintNone ((MaryEraOnwards era -> TxMintValue ViewTx era)
-> TxMintValue ViewTx era)
-> (MaryEraOnwards era -> TxMintValue ViewTx era)
-> TxMintValue ViewTx era
forall a b. (a -> b) -> a -> b
$ \MaryEraOnwards era
w ->
MaryEraOnwards era
-> (MaryEraOnwardsConstraints era => TxMintValue ViewTx era)
-> TxMintValue ViewTx era
forall era a.
MaryEraOnwards era -> (MaryEraOnwardsConstraints era => a) -> a
maryEraOnwardsConstraints MaryEraOnwards era
w ((MaryEraOnwardsConstraints era => TxMintValue ViewTx era)
-> TxMintValue ViewTx era)
-> (MaryEraOnwardsConstraints era => TxMintValue ViewTx era)
-> TxMintValue ViewTx era
forall a b. (a -> b) -> a -> b
$ do
let mint :: MaryValue StandardCrypto
mint = Coin -> MultiAsset StandardCrypto -> MaryValue StandardCrypto
forall c. Coin -> MultiAsset c -> MaryValue c
MaryValue (Integer -> Coin
Ledger.Coin Integer
0) (TxBody (ShelleyLedgerEra era)
body TxBody (ShelleyLedgerEra era)
-> Getting
(MultiAsset StandardCrypto)
(TxBody (ShelleyLedgerEra era))
(MultiAsset StandardCrypto)
-> MultiAsset StandardCrypto
forall s a. s -> Getting a s a -> a
^. (MultiAsset (EraCrypto (ShelleyLedgerEra era))
-> Const
(MultiAsset StandardCrypto)
(MultiAsset (EraCrypto (ShelleyLedgerEra era))))
-> TxBody (ShelleyLedgerEra era)
-> Const
(MultiAsset StandardCrypto) (TxBody (ShelleyLedgerEra era))
Getting
(MultiAsset StandardCrypto)
(TxBody (ShelleyLedgerEra era))
(MultiAsset StandardCrypto)
forall era.
MaryEraTxBody era =>
Lens' (TxBody era) (MultiAsset (EraCrypto era))
Lens'
(TxBody (ShelleyLedgerEra era))
(MultiAsset (EraCrypto (ShelleyLedgerEra era)))
L.mintTxBodyL)
if MaryValue StandardCrypto -> Bool
forall t. Val t => t -> Bool
L.isZero MaryValue StandardCrypto
mint
then TxMintValue ViewTx era
forall build era. TxMintValue build era
TxMintNone
else do
let assetMap :: [Item Value]
assetMap = Value -> [Item Value]
forall l. IsList l => l -> [Item l]
toList (Value -> [Item Value]) -> Value -> [Item Value]
forall a b. (a -> b) -> a -> b
$ MaryValue StandardCrypto -> Value
fromMaryValue MaryValue StandardCrypto
mint
MaryEraOnwards era
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> TxMintValue ViewTx era
forall era build.
MaryEraOnwards era
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
-> TxMintValue build era
TxMintValue MaryEraOnwards era
w (Map
PolicyId
[(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> TxMintValue ViewTx era)
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> TxMintValue ViewTx era
forall a b. (a -> b) -> a -> b
$
([(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> [(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> [(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))])
-> [(PolicyId,
[(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))])]
-> Map
PolicyId
[(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
forall k a. Ord k => (a -> a -> a) -> [(k, a)] -> Map k a
Map.fromListWith
[(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> [(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
-> [(AssetName, Quantity,
BuildTxWith ViewTx (ScriptWitness WitCtxMint era))]
forall a. Semigroup a => a -> a -> a
(<>)
[ (PolicyId
policyId', [(AssetName
assetName', Quantity
quantity, BuildTxWith ViewTx (ScriptWitness WitCtxMint era)
forall a. BuildTxWith ViewTx a
ViewTx)])
|
(AssetId PolicyId
policyId' AssetName
assetName', Quantity
quantity) <- [(AssetId, Quantity)] -> [Item [(AssetId, Quantity)]]
forall l. IsList l => l -> [Item l]
toList [(AssetId, Quantity)]
[Item Value]
assetMap
]
makeByronTransactionBody
:: ()
=> TxIns BuildTx ByronEra
-> [TxOut CtxTx ByronEra]
-> Either TxBodyError (Annotated Byron.Tx ByteString)
makeByronTransactionBody :: TxIns BuildTx ByronEra
-> [TxOut CtxTx ByronEra]
-> Either TxBodyError (Annotated Tx ByteString)
makeByronTransactionBody TxIns BuildTx ByronEra
txIns [TxOut CtxTx ByronEra]
txOuts = do
NonEmpty TxIn
ins' <- [TxIn] -> Maybe (NonEmpty TxIn)
forall a. [a] -> Maybe (NonEmpty a)
NonEmpty.nonEmpty (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn ByronEra)) -> TxIn)
-> TxIns BuildTx ByronEra -> [TxIn]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn ByronEra)) -> TxIn
forall a b. (a, b) -> a
fst TxIns BuildTx ByronEra
txIns) Maybe (NonEmpty TxIn)
-> TxBodyError -> Either TxBodyError (NonEmpty TxIn)
forall a e. Maybe a -> e -> Either e a
?! TxBodyError
TxBodyEmptyTxIns
NonEmpty TxIn
-> (TxIn -> Either TxBodyError ()) -> Either TxBodyError ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ NonEmpty TxIn
ins' ((TxIn -> Either TxBodyError ()) -> Either TxBodyError ())
-> (TxIn -> Either TxBodyError ()) -> Either TxBodyError ()
forall a b. (a -> b) -> a -> b
$ \txin :: TxIn
txin@(TxIn TxId
_ (TxIx Word
txix)) ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Word -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word
txix Word -> Word -> Bool
forall a. Ord a => a -> a -> Bool
<= Word
maxByronTxInIx) Maybe () -> TxBodyError -> Either TxBodyError ()
forall a e. Maybe a -> e -> Either e a
?! TxIn -> TxBodyError
TxBodyInIxOverflow TxIn
txin
let ins'' :: NonEmpty TxIn
ins'' = (TxIn -> TxIn) -> NonEmpty TxIn -> NonEmpty TxIn
forall a b. (a -> b) -> NonEmpty a -> NonEmpty b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TxIn -> TxIn
toByronTxIn NonEmpty TxIn
ins'
NonEmpty (TxOut CtxTx ByronEra)
outs' <- [TxOut CtxTx ByronEra] -> Maybe (NonEmpty (TxOut CtxTx ByronEra))
forall a. [a] -> Maybe (NonEmpty a)
NonEmpty.nonEmpty [TxOut CtxTx ByronEra]
txOuts Maybe (NonEmpty (TxOut CtxTx ByronEra))
-> TxBodyError
-> Either TxBodyError (NonEmpty (TxOut CtxTx ByronEra))
forall a e. Maybe a -> e -> Either e a
?! TxBodyError
TxBodyEmptyTxOuts
NonEmpty TxOut
outs'' <-
(TxOut CtxTx ByronEra -> Either TxBodyError TxOut)
-> NonEmpty (TxOut CtxTx ByronEra)
-> Either TxBodyError (NonEmpty TxOut)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> NonEmpty a -> f (NonEmpty b)
traverse
(\TxOut CtxTx ByronEra
out -> TxOut CtxTx ByronEra -> Maybe TxOut
forall ctx. TxOut ctx ByronEra -> Maybe TxOut
toByronTxOut TxOut CtxTx ByronEra
out Maybe TxOut -> TxBodyError -> Either TxBodyError TxOut
forall a e. Maybe a -> e -> Either e a
?! TxOut CtxTx ByronEra -> TxBodyError
classifyRangeError TxOut CtxTx ByronEra
out)
NonEmpty (TxOut CtxTx ByronEra)
outs'
Annotated Tx ByteString
-> Either TxBodyError (Annotated Tx ByteString)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (Annotated Tx ByteString
-> Either TxBodyError (Annotated Tx ByteString))
-> Annotated Tx ByteString
-> Either TxBodyError (Annotated Tx ByteString)
forall a b. (a -> b) -> a -> b
$
Version -> Annotated Tx () -> Annotated Tx ByteString
forall a b.
EncCBOR a =>
Version -> Annotated a b -> Annotated a ByteString
CBOR.reAnnotate Version
CBOR.byronProtVer (Annotated Tx () -> Annotated Tx ByteString)
-> Annotated Tx () -> Annotated Tx ByteString
forall a b. (a -> b) -> a -> b
$
Tx -> () -> Annotated Tx ()
forall b a. b -> a -> Annotated b a
Annotated
(NonEmpty TxIn -> NonEmpty TxOut -> TxAttributes -> Tx
Byron.UnsafeTx NonEmpty TxIn
ins'' NonEmpty TxOut
outs'' (() -> TxAttributes
forall h. h -> Attributes h
Byron.mkAttributes ()))
()
where
maxByronTxInIx :: Word
maxByronTxInIx :: Word
maxByronTxInIx = Word32 -> Word
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word32
forall a. Bounded a => a
maxBound :: Word32)
classifyRangeError :: TxOut CtxTx ByronEra -> TxBodyError
classifyRangeError :: TxOut CtxTx ByronEra -> TxBodyError
classifyRangeError TxOut CtxTx ByronEra
txout =
case TxOut CtxTx ByronEra
txout of
TxOut (AddressInEra AddressTypeInEra addrtype ByronEra
ByronAddressInAnyEra ByronAddress{}) (TxOutValueByron Coin
value) TxOutDatum CtxTx ByronEra
_ ReferenceScript ByronEra
_
| Coin
value Coin -> Coin -> Bool
forall a. Ord a => a -> a -> Bool
< Coin
0 -> Quantity -> TxOutInAnyEra -> TxBodyError
TxBodyOutputNegative (Coin -> Quantity
lovelaceToQuantity Coin
value) (CardanoEra ByronEra -> TxOut CtxTx ByronEra -> TxOutInAnyEra
forall era. CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
txOutInAnyEra CardanoEra ByronEra
ByronEra TxOut CtxTx ByronEra
txout)
| Bool
otherwise -> Quantity -> TxOutInAnyEra -> TxBodyError
TxBodyOutputOverflow (Coin -> Quantity
lovelaceToQuantity Coin
value) (CardanoEra ByronEra -> TxOut CtxTx ByronEra -> TxOutInAnyEra
forall era. CardanoEra era -> TxOut CtxTx era -> TxOutInAnyEra
txOutInAnyEra CardanoEra ByronEra
ByronEra TxOut CtxTx ByronEra
txout)
TxOut (AddressInEra AddressTypeInEra addrtype ByronEra
ByronAddressInAnyEra (ByronAddress Address
_)) (TxOutValueShelleyBased ShelleyBasedEra ByronEra
w Value (ShelleyLedgerEra ByronEra)
_) TxOutDatum CtxTx ByronEra
_ ReferenceScript ByronEra
_ -> case ShelleyBasedEra ByronEra
w of {}
TxOut (AddressInEra (ShelleyAddressInEra ShelleyBasedEra ByronEra
sbe) ShelleyAddress{}) TxOutValue ByronEra
_ TxOutDatum CtxTx ByronEra
_ ReferenceScript ByronEra
_ -> case ShelleyBasedEra ByronEra
sbe of {}
convTxIns :: TxIns BuildTx era -> Set (L.TxIn StandardCrypto)
convTxIns :: forall era. TxIns BuildTx era -> Set (TxIn StandardCrypto)
convTxIns TxIns BuildTx era
txIns = [Item (Set (TxIn StandardCrypto))] -> Set (TxIn StandardCrypto)
forall l. IsList l => [Item l] -> l
fromList (((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))
-> TxIn StandardCrypto)
-> TxIns BuildTx era -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map (TxIn -> TxIn StandardCrypto
toShelleyTxIn (TxIn -> TxIn StandardCrypto)
-> ((TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn)
-> (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))
-> TxIn StandardCrypto
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst) TxIns BuildTx era
txIns)
convCollateralTxIns :: TxInsCollateral era -> Set (Ledger.TxIn StandardCrypto)
convCollateralTxIns :: forall era. TxInsCollateral era -> Set (TxIn StandardCrypto)
convCollateralTxIns TxInsCollateral era
txInsCollateral =
case TxInsCollateral era
txInsCollateral of
TxInsCollateral era
TxInsCollateralNone -> Set (TxIn StandardCrypto)
forall a. Set a
Set.empty
TxInsCollateral AlonzoEraOnwards era
_ [TxIn]
txins -> [Item (Set (TxIn StandardCrypto))] -> Set (TxIn StandardCrypto)
forall l. IsList l => [Item l] -> l
fromList ((TxIn -> TxIn StandardCrypto) -> [TxIn] -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map TxIn -> TxIn StandardCrypto
toShelleyTxIn [TxIn]
txins)
convReturnCollateral
:: ShelleyBasedEra era
-> TxReturnCollateral ctx era
-> StrictMaybe (Ledger.TxOut (ShelleyLedgerEra era))
convReturnCollateral :: forall era ctx.
ShelleyBasedEra era
-> TxReturnCollateral ctx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
convReturnCollateral ShelleyBasedEra era
sbe TxReturnCollateral ctx era
txReturnCollateral =
case TxReturnCollateral ctx era
txReturnCollateral of
TxReturnCollateral ctx era
TxReturnCollateralNone -> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall a. StrictMaybe a
SNothing
TxReturnCollateral BabbageEraOnwards era
_ TxOut ctx era
colTxOut -> TxOut (ShelleyLedgerEra era)
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall a. a -> StrictMaybe a
SJust (TxOut (ShelleyLedgerEra era)
-> StrictMaybe (TxOut (ShelleyLedgerEra era)))
-> TxOut (ShelleyLedgerEra era)
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era
-> TxOut ctx era -> TxOut (ShelleyLedgerEra era)
forall ctx era ledgerera.
(HasCallStack, ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era -> TxOut ctx era -> TxOut ledgerera
toShelleyTxOutAny ShelleyBasedEra era
sbe TxOut ctx era
colTxOut
convTotalCollateral :: TxTotalCollateral era -> StrictMaybe Ledger.Coin
convTotalCollateral :: forall era. TxTotalCollateral era -> StrictMaybe Coin
convTotalCollateral TxTotalCollateral era
txTotalCollateral =
case TxTotalCollateral era
txTotalCollateral of
TxTotalCollateral era
TxTotalCollateralNone -> StrictMaybe Coin
forall a. StrictMaybe a
SNothing
TxTotalCollateral BabbageEraOnwards era
_ Coin
totCollLovelace -> Coin -> StrictMaybe Coin
forall a. a -> StrictMaybe a
SJust Coin
totCollLovelace
convTxOuts
:: forall ctx era ledgerera
. ShelleyLedgerEra era ~ ledgerera
=> ShelleyBasedEra era
-> [TxOut ctx era]
-> Seq.StrictSeq (Ledger.TxOut ledgerera)
convTxOuts :: forall ctx era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era
-> [TxOut ctx era] -> StrictSeq (TxOut ledgerera)
convTxOuts ShelleyBasedEra era
sbe [TxOut ctx era]
txOuts = [Item (StrictSeq (TxOut ledgerera))] -> StrictSeq (TxOut ledgerera)
forall l. IsList l => [Item l] -> l
fromList ([Item (StrictSeq (TxOut ledgerera))]
-> StrictSeq (TxOut ledgerera))
-> [Item (StrictSeq (TxOut ledgerera))]
-> StrictSeq (TxOut ledgerera)
forall a b. (a -> b) -> a -> b
$ (TxOut ctx era -> TxOut ledgerera)
-> [TxOut ctx era] -> [TxOut ledgerera]
forall a b. (a -> b) -> [a] -> [b]
map (ShelleyBasedEra era -> TxOut ctx era -> TxOut ledgerera
forall ctx era ledgerera.
(HasCallStack, ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era -> TxOut ctx era -> TxOut ledgerera
toShelleyTxOutAny ShelleyBasedEra era
sbe) [TxOut ctx era]
txOuts
convCertificates
:: ShelleyBasedEra era
-> TxCertificates build era
-> Seq.StrictSeq (Shelley.TxCert (ShelleyLedgerEra era))
convCertificates :: forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
_ = \case
TxCertificates build era
TxCertificatesNone -> StrictSeq (TxCert (ShelleyLedgerEra era))
forall a. StrictSeq a
Seq.empty
TxCertificates ShelleyBasedEra era
_ [Certificate era]
cs BuildTxWith build [(StakeCredential, Witness WitCtxStake era)]
_ -> [Item (StrictSeq (TxCert (ShelleyLedgerEra era)))]
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall l. IsList l => [Item l] -> l
fromList ((Certificate era -> TxCert (ShelleyLedgerEra era))
-> [Certificate era] -> [TxCert (ShelleyLedgerEra era)]
forall a b. (a -> b) -> [a] -> [b]
map Certificate era -> TxCert (ShelleyLedgerEra era)
forall era. Certificate era -> TxCert (ShelleyLedgerEra era)
toShelleyCertificate [Certificate era]
cs)
convWithdrawals :: TxWithdrawals build era -> L.Withdrawals StandardCrypto
convWithdrawals :: forall build era.
TxWithdrawals build era -> Withdrawals StandardCrypto
convWithdrawals TxWithdrawals build era
txWithdrawals =
case TxWithdrawals build era
txWithdrawals of
TxWithdrawals build era
TxWithdrawalsNone -> Map (RewardAccount StandardCrypto) Coin
-> Withdrawals StandardCrypto
forall c. Map (RewardAccount c) Coin -> Withdrawals c
L.Withdrawals Map (RewardAccount StandardCrypto) Coin
forall k a. Map k a
Map.empty
TxWithdrawals ShelleyBasedEra era
_ [(StakeAddress, Coin, BuildTxWith build (Witness WitCtxStake era))]
ws -> [(StakeAddress, Coin, BuildTxWith build (Witness WitCtxStake era))]
-> Withdrawals StandardCrypto
forall a. [(StakeAddress, Coin, a)] -> Withdrawals StandardCrypto
toShelleyWithdrawal [(StakeAddress, Coin, BuildTxWith build (Witness WitCtxStake era))]
ws
convTransactionFee :: ShelleyBasedEra era -> TxFee era -> Ledger.Coin
convTransactionFee :: forall era. ShelleyBasedEra era -> TxFee era -> Coin
convTransactionFee ShelleyBasedEra era
_ (TxFeeExplicit ShelleyBasedEra era
_ Coin
fee) = Coin
fee
convValidityLowerBound
:: ()
=> TxValidityLowerBound era
-> Maybe SlotNo
convValidityLowerBound :: forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound = \case
TxValidityLowerBound era
TxValidityNoLowerBound -> Maybe SlotNo
forall a. Maybe a
Nothing
TxValidityLowerBound AllegraEraOnwards era
_ SlotNo
s -> SlotNo -> Maybe SlotNo
forall a. a -> Maybe a
Just SlotNo
s
convValidityUpperBound
:: ()
=> ShelleyBasedEra era
-> TxValidityUpperBound era
-> Maybe SlotNo
convValidityUpperBound :: forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
_ = \case
TxValidityUpperBound ShelleyBasedEra era
_ Maybe SlotNo
ms -> Maybe SlotNo
ms
convTxUpdateProposal
:: ()
=> ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Ledger.Update (ShelleyLedgerEra era)))
convTxUpdateProposal :: forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe = \case
TxUpdateProposal era
TxUpdateProposalNone -> StrictMaybe (Update (ShelleyLedgerEra era))
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall a b. b -> Either a b
Right StrictMaybe (Update (ShelleyLedgerEra era))
forall a. StrictMaybe a
SNothing
TxUpdateProposal ShelleyToBabbageEra era
_ UpdateProposal
p -> (ProtocolParametersConversionError -> TxBodyError)
-> (Update (ShelleyLedgerEra era)
-> StrictMaybe (Update (ShelleyLedgerEra era)))
-> Either
ProtocolParametersConversionError (Update (ShelleyLedgerEra era))
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall a b c d. (a -> b) -> (c -> d) -> Either a c -> Either b d
forall (p :: * -> * -> *) a b c d.
Bifunctor p =>
(a -> b) -> (c -> d) -> p a c -> p b d
bimap ProtocolParametersConversionError -> TxBodyError
TxBodyProtocolParamsConversionError Update (ShelleyLedgerEra era)
-> StrictMaybe (Update (ShelleyLedgerEra era))
forall a. a -> StrictMaybe a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Either
ProtocolParametersConversionError (Update (ShelleyLedgerEra era))
-> Either
TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era))))
-> Either
ProtocolParametersConversionError (Update (ShelleyLedgerEra era))
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall a b. (a -> b) -> a -> b
$ ShelleyBasedEra era
-> UpdateProposal
-> Either
ProtocolParametersConversionError (Update (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> UpdateProposal
-> Either
ProtocolParametersConversionError (Update (ShelleyLedgerEra era))
toLedgerUpdate ShelleyBasedEra era
sbe UpdateProposal
p
convMintValue :: TxMintValue build era -> MultiAsset StandardCrypto
convMintValue :: forall build era.
TxMintValue build era -> MultiAsset StandardCrypto
convMintValue TxMintValue build era
txMintValue = do
let L.MaryValue Coin
_coin MultiAsset StandardCrypto
multiAsset = Value -> MaryValue StandardCrypto
toMaryValue (Value -> MaryValue StandardCrypto)
-> Value -> MaryValue StandardCrypto
forall a b. (a -> b) -> a -> b
$ TxMintValue build era -> Value
forall build era. TxMintValue build era -> Value
txMintValueToValue TxMintValue build era
txMintValue
MultiAsset StandardCrypto
multiAsset
convExtraKeyWitnesses
:: TxExtraKeyWitnesses era -> Set (Shelley.KeyHash Shelley.Witness StandardCrypto)
TxExtraKeyWitnesses era
txExtraKeyWits =
case TxExtraKeyWitnesses era
txExtraKeyWits of
TxExtraKeyWitnesses era
TxExtraKeyWitnessesNone -> Set (KeyHash 'Witness StandardCrypto)
forall a. Set a
Set.empty
TxExtraKeyWitnesses AlonzoEraOnwards era
_ [Hash PaymentKey]
khs ->
[Item (Set (KeyHash 'Witness StandardCrypto))]
-> Set (KeyHash 'Witness StandardCrypto)
forall l. IsList l => [Item l] -> l
fromList
[ KeyHash 'Payment StandardCrypto -> KeyHash 'Witness StandardCrypto
forall (a :: KeyRole -> * -> *) (r :: KeyRole) c.
HasKeyRole a =>
a r c -> a 'Witness c
Shelley.asWitness KeyHash 'Payment StandardCrypto
kh
| PaymentKeyHash KeyHash 'Payment StandardCrypto
kh <- [Hash PaymentKey]
khs
]
convScripts
:: ShelleyLedgerEra era ~ ledgerera
=> [(ScriptWitnessIndex, AnyScriptWitness era)]
-> [Ledger.Script ledgerera]
convScripts :: forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
[(ScriptWitnessIndex, AnyScriptWitness era)] -> [Script ledgerera]
convScripts [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnesses =
[Maybe (Script ledgerera)] -> [Script ledgerera]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra era -> Script ledgerera
ScriptInEra era -> Script (ShelleyLedgerEra era)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra era -> Script ledgerera)
-> Maybe (ScriptInEra era) -> Maybe (Script ledgerera)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx era -> Maybe (ScriptInEra era)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
getScriptWitnessScript ScriptWitness witctx era
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx era
scriptwitness) <- [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnesses
]
convScriptData
:: ()
=> ShelleyBasedEra era
-> [TxOut CtxTx era]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
-> TxBodyScriptData era
convScriptData :: forall era.
ShelleyBasedEra era
-> [TxOut CtxTx era]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
-> TxBodyScriptData era
convScriptData ShelleyBasedEra era
sbe [TxOut CtxTx era]
txOuts [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnesses =
(ShelleyToMaryEraConstraints era =>
ShelleyToMaryEra era -> TxBodyScriptData era)
-> (AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era -> TxBodyScriptData era)
-> ShelleyBasedEra era
-> TxBodyScriptData era
forall era a.
(ShelleyToMaryEraConstraints era => ShelleyToMaryEra era -> a)
-> (AlonzoEraOnwardsConstraints era => AlonzoEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToMaryOrAlonzoEraOnwards
(TxBodyScriptData era
-> ShelleyToMaryEra era -> TxBodyScriptData era
forall a b. a -> b -> a
const TxBodyScriptData era
forall era. TxBodyScriptData era
TxBodyNoScriptData)
( \AlonzoEraOnwards era
w ->
let redeemers :: Redeemers (ShelleyLedgerEra era)
redeemers =
Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
-> Redeemers (ShelleyLedgerEra era)
forall era.
AlonzoEraScript era =>
Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Redeemers era
Alonzo.Redeemers (Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
-> Redeemers (ShelleyLedgerEra era))
-> Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
-> Redeemers (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits))]
-> Map
(PlutusPurpose AsIx (ShelleyLedgerEra era))
(Data (ShelleyLedgerEra era), ExUnits)
forall l. IsList l => [Item l] -> l
fromList
[ (PlutusPurpose AsIx (ShelleyLedgerEra era)
i, (HashableScriptData -> Data (ShelleyLedgerEra era)
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d, ExecutionUnits -> ExUnits
toAlonzoExUnits ExecutionUnits
e))
| ( ScriptWitnessIndex
idx
, AnyScriptWitness
(PlutusScriptWitness ScriptLanguageInEra lang era
_ PlutusScriptVersion lang
_ PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
d ExecutionUnits
e)
) <-
[(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnesses
, Just PlutusPurpose AsIx (ShelleyLedgerEra era)
i <- [AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra era))
forall era.
AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra era))
fromScriptWitnessIndex AlonzoEraOnwards era
w ScriptWitnessIndex
idx]
]
datums :: TxDats (ShelleyLedgerEra era)
datums =
Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall era.
Era era =>
Map (DataHash (EraCrypto era)) (Data era) -> TxDats era
Alonzo.TxDats (Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era))
-> Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era))
-> TxDats (ShelleyLedgerEra era)
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era)))]
-> Map
(DataHash (EraCrypto (ShelleyLedgerEra era)))
(Data (ShelleyLedgerEra era))
forall l. IsList l => [Item l] -> l
fromList
[ (Data (ShelleyLedgerEra era)
-> DataHash (EraCrypto (ShelleyLedgerEra era))
forall era. Era era => Data era -> DataHash (EraCrypto era)
L.hashData Data (ShelleyLedgerEra era)
d', Data (ShelleyLedgerEra era)
d')
| HashableScriptData
d <- [HashableScriptData]
scriptdata
, let d' :: Data (ShelleyLedgerEra era)
d' = HashableScriptData -> Data (ShelleyLedgerEra era)
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d
]
scriptdata :: [HashableScriptData]
scriptdata :: [HashableScriptData]
scriptdata =
[HashableScriptData
d | TxOut AddressInEra era
_ TxOutValue era
_ (TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
d) ReferenceScript era
_ <- [TxOut CtxTx era]
txOuts]
[HashableScriptData]
-> [HashableScriptData] -> [HashableScriptData]
forall a. [a] -> [a] -> [a]
++ [ HashableScriptData
d
| ( ScriptWitnessIndex
_
, AnyScriptWitness
( PlutusScriptWitness
ScriptLanguageInEra lang era
_
PlutusScriptVersion lang
_
PlutusScriptOrReferenceInput lang
_
(ScriptDatumForTxIn (Just HashableScriptData
d))
HashableScriptData
_
ExecutionUnits
_
)
) <-
[(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnesses
]
in AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
forall era.
AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
TxBodyScriptData AlonzoEraOnwards era
w TxDats (ShelleyLedgerEra era)
datums Redeemers (ShelleyLedgerEra era)
redeemers
)
ShelleyBasedEra era
sbe
convPParamsToScriptIntegrityHash
:: ()
=> AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Alonzo.Redeemers (ShelleyLedgerEra era)
-> Alonzo.TxDats (ShelleyLedgerEra era)
-> Set Plutus.Language
-> StrictMaybe (L.ScriptIntegrityHash (Ledger.EraCrypto (ShelleyLedgerEra era)))
convPParamsToScriptIntegrityHash :: forall era.
AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
convPParamsToScriptIntegrityHash AlonzoEraOnwards era
w BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams Redeemers (ShelleyLedgerEra era)
redeemers TxDats (ShelleyLedgerEra era)
datums Set Language
languages =
AlonzoEraOnwards era
-> (AlonzoEraOnwardsConstraints era =>
StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era))))
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
forall era a.
AlonzoEraOnwards era -> (AlonzoEraOnwardsConstraints era => a) -> a
alonzoEraOnwardsConstraints AlonzoEraOnwards era
w ((AlonzoEraOnwardsConstraints era =>
StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era))))
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era))))
-> (AlonzoEraOnwardsConstraints era =>
StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era))))
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
forall a b. (a -> b) -> a -> b
$
case BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams of
BuildTxWith Maybe (LedgerProtocolParameters era)
Nothing -> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
StrictMaybe (ScriptIntegrityHash StandardCrypto)
forall a. StrictMaybe a
SNothing
BuildTxWith (Just (LedgerProtocolParameters PParams (ShelleyLedgerEra era)
pp)) ->
Set LangDepView
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
forall era.
AlonzoEraScript era =>
Set LangDepView
-> Redeemers era
-> TxDats era
-> StrictMaybe (ScriptIntegrityHash (EraCrypto era))
Alonzo.hashScriptIntegrity ((Language -> LangDepView) -> Set Language -> Set LangDepView
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map (PParams (ShelleyLedgerEra era) -> Language -> LangDepView
forall era.
AlonzoEraPParams era =>
PParams era -> Language -> LangDepView
L.getLanguageView PParams (ShelleyLedgerEra era)
pp) Set Language
languages) Redeemers (ShelleyLedgerEra era)
redeemers TxDats (ShelleyLedgerEra era)
datums
convLanguages :: [(ScriptWitnessIndex, AnyScriptWitness era)] -> Set Plutus.Language
convLanguages :: forall era.
[(ScriptWitnessIndex, AnyScriptWitness era)] -> Set Language
convLanguages [(ScriptWitnessIndex, AnyScriptWitness era)]
witnesses =
[Item (Set Language)] -> Set Language
forall l. IsList l => [Item l] -> l
fromList
[ AnyPlutusScriptVersion -> Language
toAlonzoLanguage (PlutusScriptVersion lang -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion lang
v)
| (ScriptWitnessIndex
_, AnyScriptWitness (PlutusScriptWitness ScriptLanguageInEra lang era
_ PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
_ ExecutionUnits
_)) <- [(ScriptWitnessIndex, AnyScriptWitness era)]
witnesses
]
convReferenceInputs :: TxInsReference era -> Set (Ledger.TxIn StandardCrypto)
convReferenceInputs :: forall era. TxInsReference era -> Set (TxIn StandardCrypto)
convReferenceInputs TxInsReference era
txInsReference =
case TxInsReference era
txInsReference of
TxInsReference era
TxInsReferenceNone -> Set (TxIn StandardCrypto)
forall a. Monoid a => a
mempty
TxInsReference BabbageEraOnwards era
_ [TxIn]
refTxins -> [Item (Set (TxIn StandardCrypto))] -> Set (TxIn StandardCrypto)
forall l. IsList l => [Item l] -> l
fromList ([Item (Set (TxIn StandardCrypto))] -> Set (TxIn StandardCrypto))
-> [Item (Set (TxIn StandardCrypto))] -> Set (TxIn StandardCrypto)
forall a b. (a -> b) -> a -> b
$ (TxIn -> TxIn StandardCrypto) -> [TxIn] -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map TxIn -> TxIn StandardCrypto
toShelleyTxIn [TxIn]
refTxins
convProposalProcedures
:: TxProposalProcedures build era -> OSet (L.ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures :: forall build era.
TxProposalProcedures build era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures TxProposalProcedures build era
TxProposalProceduresNone = OSet (ProposalProcedure (ShelleyLedgerEra era))
forall a. OSet a
OSet.empty
convProposalProcedures (TxProposalProcedures OSet (ProposalProcedure (ShelleyLedgerEra era))
pp BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
bWits) = do
let wits :: Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
wits = Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
-> Maybe
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
forall a. a -> Maybe a -> a
fromMaybe Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
forall a. Monoid a => a
mempty (Maybe
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> Maybe
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
forall a b. (a -> b) -> a -> b
$ BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
-> Maybe
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
forall build a. BuildTxWith build a -> Maybe a
buildTxWithToMaybe BuildTxWith
build
(Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era))
bWits
OSet (ProposalProcedure (ShelleyLedgerEra era))
pp OSet (ProposalProcedure (ShelleyLedgerEra era))
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall a. Ord a => OSet a -> OSet a -> OSet a
|>< [Item (OSet (ProposalProcedure (ShelleyLedgerEra era)))]
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall l. IsList l => [Item l] -> l
fromList (Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
-> [ProposalProcedure (ShelleyLedgerEra era)]
forall k a. Map k a -> [k]
Map.keys Map
(ProposalProcedure (ShelleyLedgerEra era))
(ScriptWitness WitCtxStake era)
wits)
convVotingProcedures :: TxVotingProcedures build era -> L.VotingProcedures (ShelleyLedgerEra era)
convVotingProcedures :: forall build era.
TxVotingProcedures build era
-> VotingProcedures (ShelleyLedgerEra era)
convVotingProcedures TxVotingProcedures build era
txVotingProcedures =
case TxVotingProcedures build era
txVotingProcedures of
TxVotingProcedures build era
TxVotingProceduresNone -> Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
-> VotingProcedures (ShelleyLedgerEra era)
forall era.
Map
(Voter (EraCrypto era))
(Map (GovActionId (EraCrypto era)) (VotingProcedure era))
-> VotingProcedures era
L.VotingProcedures Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(Map
(GovActionId (EraCrypto (ShelleyLedgerEra era)))
(VotingProcedure (ShelleyLedgerEra era)))
forall k a. Map k a
Map.empty
TxVotingProcedures VotingProcedures (ShelleyLedgerEra era)
vps BuildTxWith
build
(Map
(Voter (EraCrypto (ShelleyLedgerEra era)))
(ScriptWitness WitCtxStake era))
_ -> VotingProcedures (ShelleyLedgerEra era)
vps
guardShelleyTxInsOverflow :: [TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow :: [TxIn] -> Either TxBodyError ()
guardShelleyTxInsOverflow [TxIn]
txIns = do
[TxIn] -> (TxIn -> Either TxBodyError ()) -> Either TxBodyError ()
forall (t :: * -> *) (f :: * -> *) a b.
(Foldable t, Applicative f) =>
t a -> (a -> f b) -> f ()
for_ [TxIn]
txIns ((TxIn -> Either TxBodyError ()) -> Either TxBodyError ())
-> (TxIn -> Either TxBodyError ()) -> Either TxBodyError ()
forall a b. (a -> b) -> a -> b
$ \txin :: TxIn
txin@(TxIn TxId
_ (TxIx Word
txix)) ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Word
txix Word -> Word -> Bool
forall a. Ord a => a -> a -> Bool
<= Word
maxShelleyTxInIx) Maybe () -> TxBodyError -> Either TxBodyError ()
forall a e. Maybe a -> e -> Either e a
?! TxIn -> TxBodyError
TxBodyInIxOverflow TxIn
txin
mkCommonTxBody
:: ()
=> ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (L.TxAuxData (ShelleyLedgerEra era))
-> A.TxBody era
mkCommonTxBody :: forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut ctx era]
txOuts TxFee era
txFee TxWithdrawals build era
txWithdrawals Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData =
ShelleyBasedEra era
-> (ShelleyBasedEraConstraints era => TxBody era) -> TxBody era
forall era a.
ShelleyBasedEra era -> (ShelleyBasedEraConstraints era => a) -> a
shelleyBasedEraConstraints ShelleyBasedEra era
sbe ((ShelleyBasedEraConstraints era => TxBody era) -> TxBody era)
-> (ShelleyBasedEraConstraints era => TxBody era) -> TxBody era
forall a b. (a -> b) -> a -> b
$
TxBody (ShelleyLedgerEra era) -> TxBody era
forall era. TxBody (ShelleyLedgerEra era) -> TxBody era
A.TxBody (TxBody (ShelleyLedgerEra era) -> TxBody era)
-> TxBody (ShelleyLedgerEra era) -> TxBody era
forall a b. (a -> b) -> a -> b
$
TxBody (ShelleyLedgerEra era)
forall era. EraTxBody era => TxBody era
L.mkBasicTxBody
TxBody (ShelleyLedgerEra era)
-> (TxBody (ShelleyLedgerEra era) -> TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> Identity (Set (TxIn (EraCrypto (ShelleyLedgerEra era)))))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Set (TxIn (EraCrypto era)))
Lens'
(TxBody (ShelleyLedgerEra era))
(Set (TxIn (EraCrypto (ShelleyLedgerEra era))))
L.inputsTxBodyL ((Set (TxIn (EraCrypto (ShelleyLedgerEra era)))
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era)))
-> Set (TxIn StandardCrypto)
-> TxBody (ShelleyLedgerEra era)
-> TxBody (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxIns BuildTx era -> Set (TxIn StandardCrypto)
forall era. TxIns BuildTx era -> Set (TxIn StandardCrypto)
convTxIns TxIns BuildTx era
txIns
TxBody (ShelleyLedgerEra era)
-> (TxBody (ShelleyLedgerEra era) -> TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictSeq (TxOut (ShelleyLedgerEra era))
-> Identity (StrictSeq (TxOut (ShelleyLedgerEra era))))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
forall era.
EraTxBody era =>
Lens' (TxBody era) (StrictSeq (TxOut era))
Lens'
(TxBody (ShelleyLedgerEra era))
(StrictSeq (TxOut (ShelleyLedgerEra era)))
L.outputsTxBodyL ((StrictSeq (TxOut (ShelleyLedgerEra era))
-> Identity (StrictSeq (TxOut (ShelleyLedgerEra era))))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era)))
-> StrictSeq (TxOut (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
-> TxBody (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> [TxOut ctx era] -> StrictSeq (TxOut (ShelleyLedgerEra era))
forall ctx era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era
-> [TxOut ctx era] -> StrictSeq (TxOut ledgerera)
convTxOuts ShelleyBasedEra era
sbe [TxOut ctx era]
txOuts
TxBody (ShelleyLedgerEra era)
-> (TxBody (ShelleyLedgerEra era) -> TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (Coin -> Identity Coin)
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
forall era. EraTxBody era => Lens' (TxBody era) Coin
Lens' (TxBody (ShelleyLedgerEra era)) Coin
L.feeTxBodyL ((Coin -> Identity Coin)
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era)))
-> Coin
-> TxBody (ShelleyLedgerEra era)
-> TxBody (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxFee era -> Coin
forall era. ShelleyBasedEra era -> TxFee era -> Coin
convTransactionFee ShelleyBasedEra era
sbe TxFee era
txFee
TxBody (ShelleyLedgerEra era)
-> (TxBody (ShelleyLedgerEra era) -> TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (Withdrawals (EraCrypto (ShelleyLedgerEra era))
-> Identity (Withdrawals (EraCrypto (ShelleyLedgerEra era))))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
(Withdrawals (EraCrypto (ShelleyLedgerEra era))
-> Identity (Withdrawals StandardCrypto))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
forall era.
EraTxBody era =>
Lens' (TxBody era) (Withdrawals (EraCrypto era))
Lens'
(TxBody (ShelleyLedgerEra era))
(Withdrawals (EraCrypto (ShelleyLedgerEra era)))
L.withdrawalsTxBodyL ((Withdrawals (EraCrypto (ShelleyLedgerEra era))
-> Identity (Withdrawals StandardCrypto))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era)))
-> Withdrawals StandardCrypto
-> TxBody (ShelleyLedgerEra era)
-> TxBody (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxWithdrawals build era -> Withdrawals StandardCrypto
forall build era.
TxWithdrawals build era -> Withdrawals StandardCrypto
convWithdrawals TxWithdrawals build era
txWithdrawals
TxBody (ShelleyLedgerEra era)
-> (TxBody (ShelleyLedgerEra era) -> TxBody (ShelleyLedgerEra era))
-> TxBody (ShelleyLedgerEra era)
forall a b. a -> (a -> b) -> b
& (StrictMaybe (AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
-> Identity
(StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era))
forall era.
EraTxBody era =>
Lens'
(TxBody era) (StrictMaybe (AuxiliaryDataHash (EraCrypto era)))
Lens'
(TxBody (ShelleyLedgerEra era))
(StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era))))
L.auxDataHashTxBodyL ((StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
-> Identity
(StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))))
-> TxBody (ShelleyLedgerEra era)
-> Identity (TxBody (ShelleyLedgerEra era)))
-> StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
-> TxBody (ShelleyLedgerEra era)
-> TxBody (ShelleyLedgerEra era)
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
-> (TxAuxData (ShelleyLedgerEra era)
-> StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era))))
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
forall b a. b -> (a -> b) -> Maybe a -> b
maybe StrictMaybe (AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
forall a. StrictMaybe a
SNothing (AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era))
-> StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
forall a. a -> StrictMaybe a
SJust (AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era))
-> StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era))))
-> (TxAuxData (ShelleyLedgerEra era)
-> AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
-> TxAuxData (ShelleyLedgerEra era)
-> StrictMaybe
(AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era)))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxAuxData (ShelleyLedgerEra era)
-> AuxiliaryDataHash (EraCrypto (ShelleyLedgerEra era))
forall era.
EraTxAuxData era =>
TxAuxData era -> AuxiliaryDataHash (EraCrypto era)
Ledger.hashTxAuxData) Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
makeShelleyTransactionBody
:: forall era
. ()
=> ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> Either TxBodyError (TxBody era)
makeShelleyTransactionBody :: forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
makeShelleyTransactionBody
sbe :: ShelleyBasedEra era
sbe@ShelleyBasedEra era
ShelleyBasedEraShelley
txbodycontent :: TxBodyContent BuildTx era
txbodycontent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, TxFee era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
txFee
, TxValidityUpperBound era
txValidityUpperBound :: forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxUpdateProposal era
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
txUpdateProposal
} = do
let s2b :: ShelleyToBabbageEra ShelleyEra
s2b = ShelleyToBabbageEra ShelleyEra
ShelleyToBabbageEraShelley
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
StrictMaybe (Update (ShelleyEra StandardCrypto))
update <- ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe TxUpdateProposal era
txUpdateProposal
let txbody :: ShelleyTxBody (ShelleyEra StandardCrypto)
txbody =
( ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut CtxTx era]
txOuts TxFee era
txFee TxWithdrawals BuildTx era
txWithdrawals Maybe (TxAuxData (ShelleyEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (ShelleyTxCert (ShelleyEra StandardCrypto))
-> Identity
(StrictSeq (ShelleyTxCert (ShelleyEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (ShelleyTxCert (ShelleyEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe TxCertificates BuildTx era
txCertificates
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
A.updateTxBodyL ShelleyToBabbageEra era
ShelleyToBabbageEra ShelleyEra
s2b ((StrictMaybe (Update (ShelleyEra StandardCrypto))
-> Identity (StrictMaybe (Update (ShelleyEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (Update (ShelleyEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (Update (ShelleyEra StandardCrypto))
update
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe TxValidityUpperBound era
txValidityUpperBound
)
TxBody era
-> Getting
(ShelleyTxBody (ShelleyEra StandardCrypto))
(TxBody era)
(ShelleyTxBody (ShelleyEra StandardCrypto))
-> ShelleyTxBody (ShelleyEra StandardCrypto)
forall s a. s -> Getting a s a -> a
^. (TxBody (ShelleyLedgerEra era)
-> Const
(ShelleyTxBody (ShelleyEra StandardCrypto))
(TxBody (ShelleyLedgerEra era)))
-> TxBody era
-> Const (ShelleyTxBody (ShelleyEra StandardCrypto)) (TxBody era)
Getting
(ShelleyTxBody (ShelleyEra StandardCrypto))
(TxBody era)
(ShelleyTxBody (ShelleyEra StandardCrypto))
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody
ShelleyBasedEra era
sbe
TxBody (ShelleyLedgerEra era)
ShelleyTxBody (ShelleyEra StandardCrypto)
txbody
[Script (ShelleyEra StandardCrypto)]
[Script (ShelleyLedgerEra era)]
scripts_
TxBodyScriptData era
forall era. TxBodyScriptData era
TxBodyNoScriptData
Maybe (TxAuxData (ShelleyEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxScriptValidity era
forall era. TxScriptValidity era
TxScriptValidityNone
where
scripts_ :: [Ledger.Script StandardShelley]
scripts_ :: [Script (ShelleyEra StandardCrypto)]
scripts_ =
[Maybe (MultiSig (ShelleyEra StandardCrypto))]
-> [MultiSig (ShelleyEra StandardCrypto)]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra era -> Script (ShelleyLedgerEra era)
ScriptInEra era -> MultiSig (ShelleyEra StandardCrypto)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra era -> MultiSig (ShelleyEra StandardCrypto))
-> Maybe (ScriptInEra era)
-> Maybe (MultiSig (ShelleyEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx era -> Maybe (ScriptInEra era)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
getScriptWitnessScript ScriptWitness witctx era
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx era
scriptwitness) <-
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
]
txAuxData :: Maybe (L.TxAuxData StandardShelley)
txAuxData :: Maybe (TxAuxData (ShelleyEra StandardCrypto))
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
forall era. TxAuxScripts era
TxAuxScriptsNone
makeShelleyTransactionBody
sbe :: ShelleyBasedEra era
sbe@ShelleyBasedEra era
ShelleyBasedEraAllegra
txbodycontent :: TxBodyContent BuildTx era
txbodycontent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, TxFee era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
txFee
, TxValidityLowerBound era
txValidityLowerBound :: forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound
, TxValidityUpperBound era
txValidityUpperBound :: forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxAuxScripts era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxUpdateProposal era
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
txUpdateProposal
} = do
let aOn :: AllegraEraOnwards AllegraEra
aOn = AllegraEraOnwards AllegraEra
AllegraEraOnwardsAllegra
let s2b :: ShelleyToBabbageEra AllegraEra
s2b = ShelleyToBabbageEra AllegraEra
ShelleyToBabbageEraAllegra
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
StrictMaybe (Update (AllegraEra StandardCrypto))
update <- ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe TxUpdateProposal era
txUpdateProposal
let txbody :: AllegraTxBody (AllegraEra StandardCrypto)
txbody =
( ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut CtxTx era]
txOuts TxFee era
txFee TxWithdrawals BuildTx era
txWithdrawals Maybe (TxAuxData (AllegraEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (ShelleyTxCert (AllegraEra StandardCrypto))
-> Identity
(StrictSeq (ShelleyTxCert (AllegraEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (ShelleyTxCert (AllegraEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe TxCertificates BuildTx era
txCertificates
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
AllegraEraOnwards AllegraEra
aOn ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxValidityLowerBound era -> Maybe SlotNo
forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound TxValidityLowerBound era
txValidityLowerBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe TxValidityUpperBound era
txValidityUpperBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
A.updateTxBodyL ShelleyToBabbageEra era
ShelleyToBabbageEra AllegraEra
s2b ((StrictMaybe (Update (AllegraEra StandardCrypto))
-> Identity (StrictMaybe (Update (AllegraEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (Update (AllegraEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (Update (AllegraEra StandardCrypto))
update
)
TxBody era
-> Getting
(AllegraTxBody (AllegraEra StandardCrypto))
(TxBody era)
(AllegraTxBody (AllegraEra StandardCrypto))
-> AllegraTxBody (AllegraEra StandardCrypto)
forall s a. s -> Getting a s a -> a
^. Getting
(AllegraTxBody (AllegraEra StandardCrypto))
(TxBody era)
(AllegraTxBody (AllegraEra StandardCrypto))
(TxBody (ShelleyLedgerEra era)
-> Const
(AllegraTxBody (AllegraEra StandardCrypto))
(TxBody (ShelleyLedgerEra era)))
-> TxBody era
-> Const (AllegraTxBody (AllegraEra StandardCrypto)) (TxBody era)
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody
ShelleyBasedEra era
sbe
AllegraTxBody (AllegraEra StandardCrypto)
TxBody (ShelleyLedgerEra era)
txbody
[Script (AllegraEra StandardCrypto)]
[Script (ShelleyLedgerEra era)]
scripts_
TxBodyScriptData era
forall era. TxBodyScriptData era
TxBodyNoScriptData
Maybe (TxAuxData (AllegraEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxScriptValidity era
forall era. TxScriptValidity era
TxScriptValidityNone
where
scripts_ :: [Ledger.Script StandardAllegra]
scripts_ :: [Script (AllegraEra StandardCrypto)]
scripts_ =
[Maybe (Timelock (AllegraEra StandardCrypto))]
-> [Timelock (AllegraEra StandardCrypto)]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra era -> Timelock (AllegraEra StandardCrypto)
ScriptInEra era -> Script (ShelleyLedgerEra era)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra era -> Timelock (AllegraEra StandardCrypto))
-> Maybe (ScriptInEra era)
-> Maybe (Timelock (AllegraEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx era -> Maybe (ScriptInEra era)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
getScriptWitnessScript ScriptWitness witctx era
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx era
scriptwitness) <-
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
]
txAuxData :: Maybe (L.TxAuxData StandardAllegra)
txAuxData :: Maybe (TxAuxData (AllegraEra StandardCrypto))
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
txAuxScripts
makeShelleyTransactionBody
sbe :: ShelleyBasedEra era
sbe@ShelleyBasedEra era
ShelleyBasedEraMary
txbodycontent :: TxBodyContent BuildTx era
txbodycontent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, TxFee era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
txFee
, TxValidityLowerBound era
txValidityLowerBound :: forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound
, TxValidityUpperBound era
txValidityUpperBound :: forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxAuxScripts era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxUpdateProposal era
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
txUpdateProposal
, TxMintValue BuildTx era
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue BuildTx era
txMintValue
} = do
let aOn :: AllegraEraOnwards MaryEra
aOn = AllegraEraOnwards MaryEra
AllegraEraOnwardsMary
let s2b :: ShelleyToBabbageEra MaryEra
s2b = ShelleyToBabbageEra MaryEra
ShelleyToBabbageEraMary
let mOn :: MaryEraOnwards MaryEra
mOn = MaryEraOnwards MaryEra
MaryEraOnwardsMary
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
StrictMaybe (Update (MaryEra StandardCrypto))
update <- ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe TxUpdateProposal era
txUpdateProposal
let txbody :: MaryTxBody (MaryEra StandardCrypto)
txbody =
( ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut CtxTx era]
txOuts TxFee era
txFee TxWithdrawals BuildTx era
txWithdrawals Maybe (TxAuxData (MaryEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (ShelleyTxCert (MaryEra StandardCrypto))
-> Identity (StrictSeq (ShelleyTxCert (MaryEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (ShelleyTxCert (MaryEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe TxCertificates BuildTx era
txCertificates
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
AllegraEraOnwards MaryEra
aOn ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxValidityLowerBound era -> Maybe SlotNo
forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound TxValidityLowerBound era
txValidityLowerBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe TxValidityUpperBound era
txValidityUpperBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
A.updateTxBodyL ShelleyToBabbageEra era
ShelleyToBabbageEra MaryEra
s2b ((StrictMaybe (Update (MaryEra StandardCrypto))
-> Identity (StrictMaybe (Update (MaryEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (Update (MaryEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (Update (MaryEra StandardCrypto))
update
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
forall era.
MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
A.mintTxBodyL MaryEraOnwards era
MaryEraOnwards MaryEra
mOn ((MultiAsset StandardCrypto
-> Identity (MultiAsset StandardCrypto))
-> TxBody era -> Identity (TxBody era))
-> MultiAsset StandardCrypto -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxMintValue BuildTx era -> MultiAsset StandardCrypto
forall build era.
TxMintValue build era -> MultiAsset StandardCrypto
convMintValue TxMintValue BuildTx era
txMintValue
)
TxBody era
-> Getting
(MaryTxBody (MaryEra StandardCrypto))
(TxBody era)
(MaryTxBody (MaryEra StandardCrypto))
-> MaryTxBody (MaryEra StandardCrypto)
forall s a. s -> Getting a s a -> a
^. (TxBody (ShelleyLedgerEra era)
-> Const
(MaryTxBody (MaryEra StandardCrypto))
(TxBody (ShelleyLedgerEra era)))
-> TxBody era
-> Const (MaryTxBody (MaryEra StandardCrypto)) (TxBody era)
Getting
(MaryTxBody (MaryEra StandardCrypto))
(TxBody era)
(MaryTxBody (MaryEra StandardCrypto))
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody
ShelleyBasedEra era
sbe
TxBody (ShelleyLedgerEra era)
MaryTxBody (MaryEra StandardCrypto)
txbody
[Script (MaryEra StandardCrypto)]
[Script (ShelleyLedgerEra era)]
scripts
TxBodyScriptData era
forall era. TxBodyScriptData era
TxBodyNoScriptData
Maybe (TxAuxData (MaryEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxScriptValidity era
forall era. TxScriptValidity era
TxScriptValidityNone
where
scripts :: [Ledger.Script StandardMary]
scripts :: [Script (MaryEra StandardCrypto)]
scripts =
[Script (MaryEra StandardCrypto)]
-> [Script (MaryEra StandardCrypto)]
forall a. Eq a => [a] -> [a]
List.nub ([Script (MaryEra StandardCrypto)]
-> [Script (MaryEra StandardCrypto)])
-> [Script (MaryEra StandardCrypto)]
-> [Script (MaryEra StandardCrypto)]
forall a b. (a -> b) -> a -> b
$
[Maybe (Timelock (MaryEra StandardCrypto))]
-> [Timelock (MaryEra StandardCrypto)]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra era -> Timelock (MaryEra StandardCrypto)
ScriptInEra era -> Script (ShelleyLedgerEra era)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra era -> Timelock (MaryEra StandardCrypto))
-> Maybe (ScriptInEra era)
-> Maybe (Timelock (MaryEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx era -> Maybe (ScriptInEra era)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
getScriptWitnessScript ScriptWitness witctx era
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx era
scriptwitness) <-
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
]
txAuxData :: Maybe (L.TxAuxData StandardMary)
txAuxData :: Maybe (TxAuxData (MaryEra StandardCrypto))
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
txAuxScripts
makeShelleyTransactionBody
sbe :: ShelleyBasedEra era
sbe@ShelleyBasedEra era
ShelleyBasedEraAlonzo
txbodycontent :: TxBodyContent BuildTx era
txbodycontent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, TxInsCollateral era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral :: TxInsCollateral era
txInsCollateral
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, TxFee era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
txFee
, TxValidityLowerBound era
txValidityLowerBound :: forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound
, TxValidityUpperBound era
txValidityUpperBound :: forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxAuxScripts era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts
, TxExtraKeyWitnesses era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits
, BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
txProtocolParams :: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxUpdateProposal era
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
txUpdateProposal
, TxMintValue BuildTx era
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue BuildTx era
txMintValue
, TxScriptValidity era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txScriptValidity :: TxScriptValidity era
txScriptValidity
} = do
let aOn :: AllegraEraOnwards AlonzoEra
aOn = AllegraEraOnwards AlonzoEra
AllegraEraOnwardsAlonzo
let s2b :: ShelleyToBabbageEra AlonzoEra
s2b = ShelleyToBabbageEra AlonzoEra
ShelleyToBabbageEraAlonzo
let mOn :: MaryEraOnwards AlonzoEra
mOn = MaryEraOnwards AlonzoEra
MaryEraOnwardsAlonzo
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
StrictMaybe (Update (AlonzoEra StandardCrypto))
update <- ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe TxUpdateProposal era
txUpdateProposal
let scriptIntegrityHash :: StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra AlonzoEra)))
scriptIntegrityHash =
AlonzoEraOnwards AlonzoEra
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters AlonzoEra))
-> Redeemers (ShelleyLedgerEra AlonzoEra)
-> TxDats (ShelleyLedgerEra AlonzoEra)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra AlonzoEra)))
forall era.
AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
convPParamsToScriptIntegrityHash AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters AlonzoEra))
txProtocolParams Redeemers (AlonzoEra StandardCrypto)
Redeemers (ShelleyLedgerEra AlonzoEra)
redeemers TxDats (AlonzoEra StandardCrypto)
TxDats (ShelleyLedgerEra AlonzoEra)
datums Set Language
languages
let txbody :: AlonzoTxBody (AlonzoEra StandardCrypto)
txbody =
( ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut CtxTx era]
txOuts TxFee era
txFee TxWithdrawals BuildTx era
txWithdrawals Maybe (TxAuxData (AlonzoEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.collateralInputsTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
azOn ((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxInsCollateral era -> Set (TxIn StandardCrypto)
forall era. TxInsCollateral era -> Set (TxIn StandardCrypto)
convCollateralTxIns TxInsCollateral era
txInsCollateral
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (ShelleyTxCert (AlonzoEra StandardCrypto))
-> Identity (StrictSeq (ShelleyTxCert (AlonzoEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (ShelleyTxCert (AlonzoEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe TxCertificates BuildTx era
txCertificates
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
AllegraEraOnwards AlonzoEra
aOn ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxValidityLowerBound era -> Maybe SlotNo
forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound TxValidityLowerBound era
txValidityLowerBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe TxValidityUpperBound era
txValidityUpperBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
A.updateTxBodyL ShelleyToBabbageEra era
ShelleyToBabbageEra AlonzoEra
s2b ((StrictMaybe (Update (AlonzoEra StandardCrypto))
-> Identity (StrictMaybe (Update (AlonzoEra StandardCrypto))))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (Update (AlonzoEra StandardCrypto))
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (Update (AlonzoEra StandardCrypto))
update
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
A.reqSignerHashesTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
azOn ((Set (KeyHash 'Witness StandardCrypto)
-> Identity (Set (KeyHash 'Witness StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (KeyHash 'Witness StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
forall era.
TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
convExtraKeyWitnesses TxExtraKeyWitnesses era
txExtraKeyWits
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
forall era.
MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
A.mintTxBodyL MaryEraOnwards era
MaryEraOnwards AlonzoEra
mOn ((MultiAsset StandardCrypto
-> Identity (MultiAsset StandardCrypto))
-> TxBody era -> Identity (TxBody era))
-> MultiAsset StandardCrypto -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxMintValue BuildTx era -> MultiAsset StandardCrypto
forall build era.
TxMintValue build era -> MultiAsset StandardCrypto
convMintValue TxMintValue BuildTx era
txMintValue
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
A.scriptIntegrityHashTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
azOn ((StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> Identity (StrictMaybe (ScriptIntegrityHash StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra AlonzoEra)))
StrictMaybe (ScriptIntegrityHash StandardCrypto)
scriptIntegrityHash
)
TxBody era
-> Getting
(AlonzoTxBody (AlonzoEra StandardCrypto))
(TxBody era)
(AlonzoTxBody (AlonzoEra StandardCrypto))
-> AlonzoTxBody (AlonzoEra StandardCrypto)
forall s a. s -> Getting a s a -> a
^. (TxBody (ShelleyLedgerEra era)
-> Const
(AlonzoTxBody (AlonzoEra StandardCrypto))
(TxBody (ShelleyLedgerEra era)))
-> TxBody era
-> Const (AlonzoTxBody (AlonzoEra StandardCrypto)) (TxBody era)
Getting
(AlonzoTxBody (AlonzoEra StandardCrypto))
(TxBody era)
(AlonzoTxBody (AlonzoEra StandardCrypto))
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody
ShelleyBasedEra era
sbe
TxBody (ShelleyLedgerEra era)
AlonzoTxBody (AlonzoEra StandardCrypto)
txbody
[Script (AlonzoEra StandardCrypto)]
[Script (ShelleyLedgerEra era)]
scripts
(AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
forall era.
AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
TxBodyScriptData AlonzoEraOnwards era
AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo TxDats (AlonzoEra StandardCrypto)
TxDats (ShelleyLedgerEra era)
datums Redeemers (AlonzoEra StandardCrypto)
Redeemers (ShelleyLedgerEra era)
redeemers)
Maybe (TxAuxData (AlonzoEra StandardCrypto))
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxScriptValidity era
txScriptValidity
where
azOn :: AlonzoEraOnwards AlonzoEra
azOn = AlonzoEraOnwards AlonzoEra
AlonzoEraOnwardsAlonzo
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
witnesses = ShelleyBasedEra AlonzoEra
-> TxBodyContent BuildTx AlonzoEra
-> [(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
ShelleyBasedEra AlonzoEra
sbe TxBodyContent BuildTx era
TxBodyContent BuildTx AlonzoEra
txbodycontent
scripts :: [Ledger.Script StandardAlonzo]
scripts :: [Script (AlonzoEra StandardCrypto)]
scripts =
[Script (AlonzoEra StandardCrypto)]
-> [Script (AlonzoEra StandardCrypto)]
forall a. Eq a => [a] -> [a]
List.nub ([Script (AlonzoEra StandardCrypto)]
-> [Script (AlonzoEra StandardCrypto)])
-> [Script (AlonzoEra StandardCrypto)]
-> [Script (AlonzoEra StandardCrypto)]
forall a b. (a -> b) -> a -> b
$
[Maybe (AlonzoScript (AlonzoEra StandardCrypto))]
-> [AlonzoScript (AlonzoEra StandardCrypto)]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra AlonzoEra -> Script (ShelleyLedgerEra AlonzoEra)
ScriptInEra AlonzoEra -> AlonzoScript (AlonzoEra StandardCrypto)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra AlonzoEra -> AlonzoScript (AlonzoEra StandardCrypto))
-> Maybe (ScriptInEra AlonzoEra)
-> Maybe (AlonzoScript (AlonzoEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx AlonzoEra -> Maybe (ScriptInEra AlonzoEra)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
getScriptWitnessScript ScriptWitness witctx AlonzoEra
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx AlonzoEra
scriptwitness) <- [(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
witnesses
]
datums :: Alonzo.TxDats StandardAlonzo
datums :: TxDats (AlonzoEra StandardCrypto)
datums =
Map
(DataHash (EraCrypto (AlonzoEra StandardCrypto)))
(Data (AlonzoEra StandardCrypto))
-> TxDats (AlonzoEra StandardCrypto)
forall era.
Era era =>
Map (DataHash (EraCrypto era)) (Data era) -> TxDats era
Alonzo.TxDats (Map
(DataHash (EraCrypto (AlonzoEra StandardCrypto)))
(Data (AlonzoEra StandardCrypto))
-> TxDats (AlonzoEra StandardCrypto))
-> Map
(DataHash (EraCrypto (AlonzoEra StandardCrypto)))
(Data (AlonzoEra StandardCrypto))
-> TxDats (AlonzoEra StandardCrypto)
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(SafeHash StandardCrypto EraIndependentData)
(Data (AlonzoEra StandardCrypto)))]
-> Map
(SafeHash StandardCrypto EraIndependentData)
(Data (AlonzoEra StandardCrypto))
forall l. IsList l => [Item l] -> l
fromList
[ (Data (AlonzoEra StandardCrypto)
-> DataHash (EraCrypto (AlonzoEra StandardCrypto))
forall era. Era era => Data era -> DataHash (EraCrypto era)
L.hashData Data (AlonzoEra StandardCrypto)
d, Data (AlonzoEra StandardCrypto)
d)
| Data (AlonzoEra StandardCrypto)
d <- HashableScriptData -> Data (AlonzoEra StandardCrypto)
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData (HashableScriptData -> Data (AlonzoEra StandardCrypto))
-> [HashableScriptData] -> [Data (AlonzoEra StandardCrypto)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashableScriptData]
scriptdata
]
scriptdata :: [HashableScriptData]
scriptdata :: [HashableScriptData]
scriptdata =
[HashableScriptData
d | TxOut AddressInEra era
_ TxOutValue era
_ (TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
d) ReferenceScript era
_ <- [TxOut CtxTx era]
txOuts]
[HashableScriptData]
-> [HashableScriptData] -> [HashableScriptData]
forall a. [a] -> [a] -> [a]
++ [ HashableScriptData
d
| ( ScriptWitnessIndex
_
, AnyScriptWitness
( PlutusScriptWitness
ScriptLanguageInEra lang AlonzoEra
_
PlutusScriptVersion lang
_
PlutusScriptOrReferenceInput lang
_
(ScriptDatumForTxIn (Just HashableScriptData
d))
HashableScriptData
_
ExecutionUnits
_
)
) <-
[(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
witnesses
]
redeemers :: Alonzo.Redeemers StandardAlonzo
redeemers :: Redeemers (AlonzoEra StandardCrypto)
redeemers =
Map
(PlutusPurpose AsIx (AlonzoEra StandardCrypto))
(Data (AlonzoEra StandardCrypto), ExUnits)
-> Redeemers (AlonzoEra StandardCrypto)
forall era.
AlonzoEraScript era =>
Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Redeemers era
Alonzo.Redeemers (Map
(PlutusPurpose AsIx (AlonzoEra StandardCrypto))
(Data (AlonzoEra StandardCrypto), ExUnits)
-> Redeemers (AlonzoEra StandardCrypto))
-> Map
(PlutusPurpose AsIx (AlonzoEra StandardCrypto))
(Data (AlonzoEra StandardCrypto), ExUnits)
-> Redeemers (AlonzoEra StandardCrypto)
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto))
(Data (AlonzoEra StandardCrypto), ExUnits))]
-> Map
(AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto))
(Data (AlonzoEra StandardCrypto), ExUnits)
forall l. IsList l => [Item l] -> l
fromList
[ (AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto)
i, (HashableScriptData -> Data (AlonzoEra StandardCrypto)
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d, ExecutionUnits -> ExUnits
toAlonzoExUnits ExecutionUnits
e))
| ( ScriptWitnessIndex
idx
, AnyScriptWitness
(PlutusScriptWitness ScriptLanguageInEra lang AlonzoEra
_ PlutusScriptVersion lang
_ PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
d ExecutionUnits
e)
) <-
[(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
witnesses
, Just AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto)
i <- [AlonzoEraOnwards AlonzoEra
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall era.
AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra era))
fromScriptWitnessIndex AlonzoEraOnwards AlonzoEra
azOn ScriptWitnessIndex
idx]
]
languages :: Set Plutus.Language
languages :: Set Language
languages =
[Item (Set Language)] -> Set Language
forall l. IsList l => [Item l] -> l
fromList
[ AnyPlutusScriptVersion -> Language
toAlonzoLanguage (PlutusScriptVersion lang -> AnyPlutusScriptVersion
forall lang.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion lang
v)
| (ScriptWitnessIndex
_, AnyScriptWitness (PlutusScriptWitness ScriptLanguageInEra lang AlonzoEra
_ PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
_ ExecutionUnits
_)) <- [(ScriptWitnessIndex, AnyScriptWitness AlonzoEra)]
witnesses
]
txAuxData :: Maybe (L.TxAuxData StandardAlonzo)
txAuxData :: Maybe (TxAuxData (AlonzoEra StandardCrypto))
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
txAuxScripts
makeShelleyTransactionBody
sbe :: ShelleyBasedEra era
sbe@ShelleyBasedEra era
ShelleyBasedEraBabbage
txbodycontent :: TxBodyContent BuildTx era
txbodycontent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, TxInsCollateral era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral :: TxInsCollateral era
txInsCollateral
, TxInsReference era
txInsReference :: forall build era. TxBodyContent build era -> TxInsReference era
txInsReference :: TxInsReference era
txInsReference
, TxReturnCollateral CtxTx era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txReturnCollateral :: TxReturnCollateral CtxTx era
txReturnCollateral
, TxTotalCollateral era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txTotalCollateral :: TxTotalCollateral era
txTotalCollateral
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, TxFee era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
txFee
, TxValidityLowerBound era
txValidityLowerBound :: forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound
, TxValidityUpperBound era
txValidityUpperBound :: forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxAuxScripts era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts
, TxExtraKeyWitnesses era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits
, BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
txProtocolParams :: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxUpdateProposal era
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txUpdateProposal :: TxUpdateProposal era
txUpdateProposal
, TxMintValue BuildTx era
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue BuildTx era
txMintValue
, TxScriptValidity era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txScriptValidity :: TxScriptValidity era
txScriptValidity
} = do
let aOn :: AllegraEraOnwards BabbageEra
aOn = AllegraEraOnwards BabbageEra
AllegraEraOnwardsBabbage
let mOn :: MaryEraOnwards BabbageEra
mOn = MaryEraOnwards BabbageEra
MaryEraOnwardsBabbage
let bOn :: BabbageEraOnwards BabbageEra
bOn = BabbageEraOnwards BabbageEra
BabbageEraOnwardsBabbage
let s2b :: ShelleyToBabbageEra BabbageEra
s2b = ShelleyToBabbageEra BabbageEra
ShelleyToBabbageEraBabbage
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
StrictMaybe (Update StandardBabbage)
update <- ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> TxUpdateProposal era
-> Either TxBodyError (StrictMaybe (Update (ShelleyLedgerEra era)))
convTxUpdateProposal ShelleyBasedEra era
sbe TxUpdateProposal era
txUpdateProposal
let scriptIntegrityHash :: StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra BabbageEra)))
scriptIntegrityHash =
AlonzoEraOnwards BabbageEra
-> BuildTxWith
BuildTx (Maybe (LedgerProtocolParameters BabbageEra))
-> Redeemers (ShelleyLedgerEra BabbageEra)
-> TxDats (ShelleyLedgerEra BabbageEra)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra BabbageEra)))
forall era.
AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
convPParamsToScriptIntegrityHash AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters BabbageEra))
txProtocolParams Redeemers StandardBabbage
Redeemers (ShelleyLedgerEra BabbageEra)
redeemers TxDats StandardBabbage
TxDats (ShelleyLedgerEra BabbageEra)
datums Set Language
languages
let txbody :: BabbageTxBody StandardBabbage
txbody =
( ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut CtxTx era]
txOuts TxFee era
txFee TxWithdrawals BuildTx era
txWithdrawals Maybe (TxAuxData StandardBabbage)
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.collateralInputsTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
azOn ((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxInsCollateral era -> Set (TxIn StandardCrypto)
forall era. TxInsCollateral era -> Set (TxIn StandardCrypto)
convCollateralTxIns TxInsCollateral era
txInsCollateral
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& BabbageEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
BabbageEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.referenceInputsTxBodyL BabbageEraOnwards era
BabbageEraOnwards BabbageEra
bOn ((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxInsReference era -> Set (TxIn StandardCrypto)
forall era. TxInsReference era -> Set (TxIn StandardCrypto)
convReferenceInputs TxInsReference era
txInsReference
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& BabbageEraOnwards era
-> Lens' (TxBody era) (StrictMaybe (TxOut (ShelleyLedgerEra era)))
forall era.
BabbageEraOnwards era
-> Lens' (TxBody era) (StrictMaybe (TxOut (ShelleyLedgerEra era)))
A.collateralReturnTxBodyL BabbageEraOnwards era
BabbageEraOnwards BabbageEra
bOn ((StrictMaybe (BabbageTxOut StandardBabbage)
-> Identity (StrictMaybe (BabbageTxOut StandardBabbage)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (BabbageTxOut StandardBabbage)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxReturnCollateral CtxTx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall era ctx.
ShelleyBasedEra era
-> TxReturnCollateral ctx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
convReturnCollateral ShelleyBasedEra era
sbe TxReturnCollateral CtxTx era
txReturnCollateral
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& BabbageEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
forall era.
BabbageEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
A.totalCollateralTxBodyL BabbageEraOnwards era
BabbageEraOnwards BabbageEra
bOn ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxTotalCollateral era -> StrictMaybe Coin
forall era. TxTotalCollateral era -> StrictMaybe Coin
convTotalCollateral TxTotalCollateral era
txTotalCollateral
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (ShelleyTxCert StandardBabbage)
-> Identity (StrictSeq (ShelleyTxCert StandardBabbage)))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (ShelleyTxCert StandardBabbage)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe TxCertificates BuildTx era
txCertificates
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
AllegraEraOnwards BabbageEra
aOn ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxValidityLowerBound era -> Maybe SlotNo
forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound TxValidityLowerBound era
txValidityLowerBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe TxValidityUpperBound era
txValidityUpperBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
forall era.
ShelleyToBabbageEra era
-> Lens' (TxBody era) (StrictMaybe (Update (ShelleyLedgerEra era)))
A.updateTxBodyL ShelleyToBabbageEra era
ShelleyToBabbageEra BabbageEra
s2b ((StrictMaybe (Update StandardBabbage)
-> Identity (StrictMaybe (Update StandardBabbage)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (Update StandardBabbage) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe (Update StandardBabbage)
update
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
A.reqSignerHashesTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
azOn ((Set (KeyHash 'Witness StandardCrypto)
-> Identity (Set (KeyHash 'Witness StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (KeyHash 'Witness StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
forall era.
TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
convExtraKeyWitnesses TxExtraKeyWitnesses era
txExtraKeyWits
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
forall era.
MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
A.mintTxBodyL MaryEraOnwards era
MaryEraOnwards BabbageEra
mOn ((MultiAsset StandardCrypto
-> Identity (MultiAsset StandardCrypto))
-> TxBody era -> Identity (TxBody era))
-> MultiAsset StandardCrypto -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxMintValue BuildTx era -> MultiAsset StandardCrypto
forall build era.
TxMintValue build era -> MultiAsset StandardCrypto
convMintValue TxMintValue BuildTx era
txMintValue
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
A.scriptIntegrityHashTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
azOn ((StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> Identity (StrictMaybe (ScriptIntegrityHash StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra BabbageEra)))
StrictMaybe (ScriptIntegrityHash StandardCrypto)
scriptIntegrityHash
)
TxBody era
-> Getting
(BabbageTxBody StandardBabbage)
(TxBody era)
(BabbageTxBody StandardBabbage)
-> BabbageTxBody StandardBabbage
forall s a. s -> Getting a s a -> a
^. (TxBody (ShelleyLedgerEra era)
-> Const
(BabbageTxBody StandardBabbage) (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> Const (BabbageTxBody StandardBabbage) (TxBody era)
Getting
(BabbageTxBody StandardBabbage)
(TxBody era)
(BabbageTxBody StandardBabbage)
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody
ShelleyBasedEra era
sbe
TxBody (ShelleyLedgerEra era)
BabbageTxBody StandardBabbage
txbody
[Script StandardBabbage]
[Script (ShelleyLedgerEra era)]
scripts
( AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
forall era.
AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
TxBodyScriptData
AlonzoEraOnwards era
AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage
TxDats StandardBabbage
TxDats (ShelleyLedgerEra era)
datums
Redeemers StandardBabbage
Redeemers (ShelleyLedgerEra era)
redeemers
)
Maybe (TxAuxData StandardBabbage)
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxScriptValidity era
txScriptValidity
where
azOn :: AlonzoEraOnwards BabbageEra
azOn = AlonzoEraOnwards BabbageEra
AlonzoEraOnwardsBabbage
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses = ShelleyBasedEra BabbageEra
-> TxBodyContent BuildTx BabbageEra
-> [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
ShelleyBasedEra BabbageEra
sbe TxBodyContent BuildTx era
TxBodyContent BuildTx BabbageEra
txbodycontent
scripts :: [Ledger.Script StandardBabbage]
scripts :: [Script StandardBabbage]
scripts =
[Script StandardBabbage] -> [Script StandardBabbage]
forall a. Eq a => [a] -> [a]
List.nub ([Script StandardBabbage] -> [Script StandardBabbage])
-> [Script StandardBabbage] -> [Script StandardBabbage]
forall a b. (a -> b) -> a -> b
$
[Maybe (AlonzoScript StandardBabbage)]
-> [AlonzoScript StandardBabbage]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra BabbageEra -> Script (ShelleyLedgerEra BabbageEra)
ScriptInEra BabbageEra -> AlonzoScript StandardBabbage
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra BabbageEra -> AlonzoScript StandardBabbage)
-> Maybe (ScriptInEra BabbageEra)
-> Maybe (AlonzoScript StandardBabbage)
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)
getScriptWitnessScript ScriptWitness witctx BabbageEra
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx BabbageEra
scriptwitness) <- [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
]
datums :: Alonzo.TxDats StandardBabbage
datums :: TxDats StandardBabbage
datums =
Map (DataHash (EraCrypto StandardBabbage)) (Data StandardBabbage)
-> TxDats StandardBabbage
forall era.
Era era =>
Map (DataHash (EraCrypto era)) (Data era) -> TxDats era
Alonzo.TxDats (Map (DataHash (EraCrypto StandardBabbage)) (Data StandardBabbage)
-> TxDats StandardBabbage)
-> Map
(DataHash (EraCrypto StandardBabbage)) (Data StandardBabbage)
-> TxDats StandardBabbage
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(SafeHash StandardCrypto EraIndependentData)
(Data StandardBabbage))]
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data StandardBabbage)
forall l. IsList l => [Item l] -> l
fromList
[ (Data StandardBabbage -> DataHash (EraCrypto StandardBabbage)
forall era. Era era => Data era -> DataHash (EraCrypto era)
L.hashData Data StandardBabbage
d', Data StandardBabbage
d')
| HashableScriptData
d <- [HashableScriptData]
scriptdata
, let d' :: Data StandardBabbage
d' = HashableScriptData -> Data StandardBabbage
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d
]
scriptdata :: [HashableScriptData]
scriptdata :: [HashableScriptData]
scriptdata =
[HashableScriptData
d | TxOut AddressInEra era
_ TxOutValue era
_ (TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
d) ReferenceScript era
_ <- [TxOut CtxTx era]
txOuts]
[HashableScriptData]
-> [HashableScriptData] -> [HashableScriptData]
forall a. [a] -> [a] -> [a]
++ [ HashableScriptData
d
| ( ScriptWitnessIndex
_
, AnyScriptWitness
( PlutusScriptWitness
ScriptLanguageInEra lang BabbageEra
_
PlutusScriptVersion lang
_
PlutusScriptOrReferenceInput lang
_
(ScriptDatumForTxIn (Just HashableScriptData
d))
HashableScriptData
_
ExecutionUnits
_
)
) <-
[(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
]
redeemers :: Alonzo.Redeemers StandardBabbage
redeemers :: Redeemers StandardBabbage
redeemers =
Map
(PlutusPurpose AsIx StandardBabbage)
(Data StandardBabbage, ExUnits)
-> Redeemers StandardBabbage
forall era.
AlonzoEraScript era =>
Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Redeemers era
Alonzo.Redeemers (Map
(PlutusPurpose AsIx StandardBabbage)
(Data StandardBabbage, ExUnits)
-> Redeemers StandardBabbage)
-> Map
(PlutusPurpose AsIx StandardBabbage)
(Data StandardBabbage, ExUnits)
-> Redeemers StandardBabbage
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(AlonzoPlutusPurpose AsIx StandardBabbage)
(Data StandardBabbage, ExUnits))]
-> Map
(AlonzoPlutusPurpose AsIx StandardBabbage)
(Data StandardBabbage, ExUnits)
forall l. IsList l => [Item l] -> l
fromList
[ (AlonzoPlutusPurpose AsIx StandardBabbage
i, (HashableScriptData -> Data StandardBabbage
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d, ExecutionUnits -> ExUnits
toAlonzoExUnits ExecutionUnits
e))
| ( ScriptWitnessIndex
idx
, AnyScriptWitness
(PlutusScriptWitness ScriptLanguageInEra lang BabbageEra
_ PlutusScriptVersion lang
_ PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
d ExecutionUnits
e)
) <-
[(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
, Just AlonzoPlutusPurpose AsIx StandardBabbage
i <- [AlonzoEraOnwards BabbageEra
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall era.
AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra era))
fromScriptWitnessIndex AlonzoEraOnwards BabbageEra
azOn ScriptWitnessIndex
idx]
]
languages :: Set Plutus.Language
languages :: Set Language
languages =
[Item (Set Language)] -> Set Language
forall l. IsList l => [Item l] -> l
fromList ([Item (Set Language)] -> Set Language)
-> [Item (Set Language)] -> Set Language
forall a b. (a -> b) -> a -> b
$
[Maybe Language] -> [Language]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptWitness witctx era -> Maybe Language
forall witctx. ScriptWitness witctx era -> Maybe Language
getScriptLanguage ScriptWitness witctx era
ScriptWitness witctx BabbageEra
sw
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx BabbageEra
sw) <- [(ScriptWitnessIndex, AnyScriptWitness BabbageEra)]
witnesses
]
getScriptLanguage :: ScriptWitness witctx era -> Maybe Plutus.Language
getScriptLanguage :: forall witctx. ScriptWitness witctx era -> Maybe Language
getScriptLanguage (PlutusScriptWitness ScriptLanguageInEra lang era
_ PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
_ 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.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion lang
v)
getScriptLanguage SimpleScriptWitness{} = Maybe Language
forall a. Maybe a
Nothing
txAuxData :: Maybe (L.TxAuxData StandardBabbage)
txAuxData :: Maybe (TxAuxData StandardBabbage)
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
txAuxScripts
makeShelleyTransactionBody
sbe :: ShelleyBasedEra era
sbe@ShelleyBasedEra era
ShelleyBasedEraConway
txbodycontent :: TxBodyContent BuildTx era
txbodycontent@TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, TxInsCollateral era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txInsCollateral :: TxInsCollateral era
txInsCollateral
, TxInsReference era
txInsReference :: forall build era. TxBodyContent build era -> TxInsReference era
txInsReference :: TxInsReference era
txInsReference
, TxReturnCollateral CtxTx era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txReturnCollateral :: TxReturnCollateral CtxTx era
txReturnCollateral
, TxTotalCollateral era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txTotalCollateral :: TxTotalCollateral era
txTotalCollateral
, [TxOut CtxTx era]
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txOuts :: [TxOut CtxTx era]
txOuts
, TxFee era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txFee :: TxFee era
txFee
, TxValidityLowerBound era
txValidityLowerBound :: forall build era.
TxBodyContent build era -> TxValidityLowerBound era
txValidityLowerBound :: TxValidityLowerBound era
txValidityLowerBound
, TxValidityUpperBound era
txValidityUpperBound :: forall build era.
TxBodyContent build era -> TxValidityUpperBound era
txValidityUpperBound :: TxValidityUpperBound era
txValidityUpperBound
, TxMetadataInEra era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txMetadata :: TxMetadataInEra era
txMetadata
, TxAuxScripts era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txAuxScripts :: TxAuxScripts era
txAuxScripts
, TxExtraKeyWitnesses era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txExtraKeyWits :: TxExtraKeyWitnesses era
txExtraKeyWits
, BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
txProtocolParams :: BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
txProtocolParams
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxMintValue BuildTx era
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue BuildTx era
txMintValue
, TxScriptValidity era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txScriptValidity :: TxScriptValidity era
txScriptValidity
, Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures :: forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures build era))
txProposalProcedures :: Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures
, Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures :: forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures build era))
txVotingProcedures :: Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures
, Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue :: forall build era.
TxBodyContent build era
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue :: Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue
, Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation :: forall build era.
TxBodyContent build era
-> Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation :: Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation
} = do
let aOn :: AllegraEraOnwards ConwayEra
aOn = AllegraEraOnwards ConwayEra
AllegraEraOnwardsConway
let cOn :: ConwayEraOnwards ConwayEra
cOn = ConwayEraOnwards ConwayEra
ConwayEraOnwardsConway
let mOn :: MaryEraOnwards ConwayEra
mOn = MaryEraOnwards ConwayEra
MaryEraOnwardsConway
let bOn :: BabbageEraOnwards ConwayEra
bOn = BabbageEraOnwards ConwayEra
BabbageEraOnwardsConway
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError ()
validateTxBodyContent ShelleyBasedEra era
sbe TxBodyContent BuildTx era
txbodycontent
let scriptIntegrityHash :: StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra ConwayEra)))
scriptIntegrityHash =
AlonzoEraOnwards ConwayEra
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters ConwayEra))
-> Redeemers (ShelleyLedgerEra ConwayEra)
-> TxDats (ShelleyLedgerEra ConwayEra)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra ConwayEra)))
forall era.
AlonzoEraOnwards era
-> BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
-> Redeemers (ShelleyLedgerEra era)
-> TxDats (ShelleyLedgerEra era)
-> Set Language
-> StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra era)))
convPParamsToScriptIntegrityHash AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway BuildTxWith BuildTx (Maybe (LedgerProtocolParameters era))
BuildTxWith BuildTx (Maybe (LedgerProtocolParameters ConwayEra))
txProtocolParams Redeemers StandardConway
Redeemers (ShelleyLedgerEra ConwayEra)
redeemers TxDats StandardConway
TxDats (ShelleyLedgerEra ConwayEra)
datums Set Language
languages
let txbody :: ConwayTxBody StandardConway
txbody =
( ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut CtxTx era]
-> TxFee era
-> TxWithdrawals BuildTx era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
forall era ctx build.
ShelleyBasedEra era
-> TxIns BuildTx era
-> [TxOut ctx era]
-> TxFee era
-> TxWithdrawals build era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxBody era
mkCommonTxBody ShelleyBasedEra era
sbe TxIns BuildTx era
txIns [TxOut CtxTx era]
txOuts TxFee era
txFee TxWithdrawals BuildTx era
txWithdrawals Maybe (TxAuxData StandardConway)
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.collateralInputsTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
azOn
((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ case TxInsCollateral era
txInsCollateral of
TxInsCollateral era
TxInsCollateralNone -> Set (TxIn StandardCrypto)
forall a. Set a
Set.empty
TxInsCollateral AlonzoEraOnwards era
_ [TxIn]
txins -> [Item (Set (TxIn StandardCrypto))] -> Set (TxIn StandardCrypto)
forall l. IsList l => [Item l] -> l
fromList ((TxIn -> TxIn StandardCrypto) -> [TxIn] -> [TxIn StandardCrypto]
forall a b. (a -> b) -> [a] -> [b]
map TxIn -> TxIn StandardCrypto
toShelleyTxIn [TxIn]
txins)
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& BabbageEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
forall era.
BabbageEraOnwards era
-> Lens' (TxBody era) (Set (TxIn StandardCrypto))
A.referenceInputsTxBodyL BabbageEraOnwards era
BabbageEraOnwards ConwayEra
bOn ((Set (TxIn StandardCrypto)
-> Identity (Set (TxIn StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (TxIn StandardCrypto) -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxInsReference era -> Set (TxIn StandardCrypto)
forall era. TxInsReference era -> Set (TxIn StandardCrypto)
convReferenceInputs TxInsReference era
txInsReference
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& BabbageEraOnwards era
-> Lens' (TxBody era) (StrictMaybe (TxOut (ShelleyLedgerEra era)))
forall era.
BabbageEraOnwards era
-> Lens' (TxBody era) (StrictMaybe (TxOut (ShelleyLedgerEra era)))
A.collateralReturnTxBodyL BabbageEraOnwards era
BabbageEraOnwards ConwayEra
bOn ((StrictMaybe (BabbageTxOut StandardConway)
-> Identity (StrictMaybe (BabbageTxOut StandardConway)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (BabbageTxOut StandardConway)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxReturnCollateral CtxTx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
forall era ctx.
ShelleyBasedEra era
-> TxReturnCollateral ctx era
-> StrictMaybe (TxOut (ShelleyLedgerEra era))
convReturnCollateral ShelleyBasedEra era
sbe TxReturnCollateral CtxTx era
txReturnCollateral
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& BabbageEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
forall era.
BabbageEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
A.totalCollateralTxBodyL BabbageEraOnwards era
BabbageEraOnwards ConwayEra
bOn ((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxTotalCollateral era -> StrictMaybe Coin
forall era. TxTotalCollateral era -> StrictMaybe Coin
convTotalCollateral TxTotalCollateral era
txTotalCollateral
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
forall era.
ShelleyBasedEra era
-> Lens' (TxBody era) (StrictSeq (TxCert (ShelleyLedgerEra era)))
A.certsTxBodyL ShelleyBasedEra era
sbe ((StrictSeq (ConwayTxCert StandardConway)
-> Identity (StrictSeq (ConwayTxCert StandardConway)))
-> TxBody era -> Identity (TxBody era))
-> StrictSeq (ConwayTxCert StandardConway)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> TxCertificates BuildTx era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
forall era build.
ShelleyBasedEra era
-> TxCertificates build era
-> StrictSeq (TxCert (ShelleyLedgerEra era))
convCertificates ShelleyBasedEra era
sbe TxCertificates BuildTx era
txCertificates
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
AllegraEraOnwards era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidBeforeTxBodyL AllegraEraOnwards era
AllegraEraOnwards ConwayEra
aOn ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxValidityLowerBound era -> Maybe SlotNo
forall era. TxValidityLowerBound era -> Maybe SlotNo
convValidityLowerBound TxValidityLowerBound era
txValidityLowerBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
forall era.
ShelleyBasedEra era -> Lens' (TxBody era) (Maybe SlotNo)
A.invalidHereAfterTxBodyL ShelleyBasedEra era
sbe ((Maybe SlotNo -> Identity (Maybe SlotNo))
-> TxBody era -> Identity (TxBody era))
-> Maybe SlotNo -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
forall era.
ShelleyBasedEra era -> TxValidityUpperBound era -> Maybe SlotNo
convValidityUpperBound ShelleyBasedEra era
sbe TxValidityUpperBound era
txValidityUpperBound
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens' (TxBody era) (Set (KeyHash 'Witness StandardCrypto))
A.reqSignerHashesTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
azOn ((Set (KeyHash 'Witness StandardCrypto)
-> Identity (Set (KeyHash 'Witness StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> Set (KeyHash 'Witness StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
forall era.
TxExtraKeyWitnesses era -> Set (KeyHash 'Witness StandardCrypto)
convExtraKeyWitnesses TxExtraKeyWitnesses era
txExtraKeyWits
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
forall era.
MaryEraOnwards era
-> Lens' (TxBody era) (MultiAsset StandardCrypto)
A.mintTxBodyL MaryEraOnwards era
MaryEraOnwards ConwayEra
mOn ((MultiAsset StandardCrypto
-> Identity (MultiAsset StandardCrypto))
-> TxBody era -> Identity (TxBody era))
-> MultiAsset StandardCrypto -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxMintValue BuildTx era -> MultiAsset StandardCrypto
forall build era.
TxMintValue build era -> MultiAsset StandardCrypto
convMintValue TxMintValue BuildTx era
txMintValue
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
forall era.
AlonzoEraOnwards era
-> Lens'
(TxBody era) (StrictMaybe (ScriptIntegrityHash StandardCrypto))
A.scriptIntegrityHashTxBodyL AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
azOn ((StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> Identity (StrictMaybe (ScriptIntegrityHash StandardCrypto)))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe (ScriptIntegrityHash StandardCrypto)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ StrictMaybe
(ScriptIntegrityHash (EraCrypto (ShelleyLedgerEra ConwayEra)))
StrictMaybe (ScriptIntegrityHash StandardCrypto)
scriptIntegrityHash
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ConwayEraOnwards era
-> Lens' (TxBody era) (VotingProcedures (ShelleyLedgerEra era))
forall era.
ConwayEraOnwards era
-> Lens' (TxBody era) (VotingProcedures (ShelleyLedgerEra era))
A.votingProceduresTxBodyL ConwayEraOnwards era
ConwayEraOnwards ConwayEra
cOn
((VotingProcedures StandardConway
-> Identity (VotingProcedures StandardConway))
-> TxBody era -> Identity (TxBody era))
-> VotingProcedures StandardConway -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxVotingProcedures BuildTx era
-> VotingProcedures (ShelleyLedgerEra era)
forall build era.
TxVotingProcedures build era
-> VotingProcedures (ShelleyLedgerEra era)
convVotingProcedures (TxVotingProcedures BuildTx era
-> (Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era)
-> TxVotingProcedures BuildTx era)
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
-> TxVotingProcedures BuildTx era
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TxVotingProcedures BuildTx era
forall build era. TxVotingProcedures build era
TxVotingProceduresNone Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era)
-> TxVotingProcedures BuildTx era
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures)
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ConwayEraOnwards era
-> Lens'
(TxBody era) (OSet (ProposalProcedure (ShelleyLedgerEra era)))
forall era.
ConwayEraOnwards era
-> Lens'
(TxBody era) (OSet (ProposalProcedure (ShelleyLedgerEra era)))
A.proposalProceduresTxBodyL ConwayEraOnwards era
ConwayEraOnwards ConwayEra
cOn
((OSet (ProposalProcedure StandardConway)
-> Identity (OSet (ProposalProcedure StandardConway)))
-> TxBody era -> Identity (TxBody era))
-> OSet (ProposalProcedure StandardConway)
-> TxBody era
-> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxProposalProcedures BuildTx era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
forall build era.
TxProposalProcedures build era
-> OSet (ProposalProcedure (ShelleyLedgerEra era))
convProposalProcedures (TxProposalProcedures BuildTx era
-> (Featured
ConwayEraOnwards era (TxProposalProcedures BuildTx era)
-> TxProposalProcedures BuildTx era)
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
-> TxProposalProcedures BuildTx era
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TxProposalProcedures BuildTx era
forall build era. TxProposalProcedures build era
TxProposalProceduresNone Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era)
-> TxProposalProcedures BuildTx era
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures)
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ConwayEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
forall era.
ConwayEraOnwards era -> Lens' (TxBody era) (StrictMaybe Coin)
A.currentTreasuryValueTxBodyL ConwayEraOnwards era
ConwayEraOnwards ConwayEra
cOn
((StrictMaybe Coin -> Identity (StrictMaybe Coin))
-> TxBody era -> Identity (TxBody era))
-> StrictMaybe Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Maybe Coin -> StrictMaybe Coin
forall a. Maybe a -> StrictMaybe a
Ledger.maybeToStrictMaybe (Featured ConwayEraOnwards era (Maybe Coin) -> Maybe Coin
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured (Featured ConwayEraOnwards era (Maybe Coin) -> Maybe Coin)
-> Maybe (Featured ConwayEraOnwards era (Maybe Coin)) -> Maybe Coin
forall (m :: * -> *) a b. Monad m => (a -> m b) -> m a -> m b
=<< Maybe (Featured ConwayEraOnwards era (Maybe Coin))
txCurrentTreasuryValue)
TxBody era -> (TxBody era -> TxBody era) -> TxBody era
forall a b. a -> (a -> b) -> b
& ConwayEraOnwards era -> Lens' (TxBody era) Coin
forall era. ConwayEraOnwards era -> Lens' (TxBody era) Coin
A.treasuryDonationTxBodyL ConwayEraOnwards era
ConwayEraOnwards ConwayEra
cOn ((Coin -> Identity Coin) -> TxBody era -> Identity (TxBody era))
-> Coin -> TxBody era -> TxBody era
forall s t a b. ASetter s t a b -> b -> s -> t
.~ Coin
-> (Featured ConwayEraOnwards era Coin -> Coin)
-> Maybe (Featured ConwayEraOnwards era Coin)
-> Coin
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (Integer -> Coin
L.Coin Integer
0) Featured ConwayEraOnwards era Coin -> Coin
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured Maybe (Featured ConwayEraOnwards era Coin)
txTreasuryDonation
)
TxBody era
-> Getting
(ConwayTxBody StandardConway)
(TxBody era)
(ConwayTxBody StandardConway)
-> ConwayTxBody StandardConway
forall s a. s -> Getting a s a -> a
^. (TxBody (ShelleyLedgerEra era)
-> Const
(ConwayTxBody StandardConway) (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> Const (ConwayTxBody StandardConway) (TxBody era)
Getting
(ConwayTxBody StandardConway)
(TxBody era)
(ConwayTxBody StandardConway)
forall era (f :: * -> *).
Functor f =>
(TxBody (ShelleyLedgerEra era)
-> f (TxBody (ShelleyLedgerEra era)))
-> TxBody era -> f (TxBody era)
A.txBodyL
TxBody era -> Either TxBodyError (TxBody era)
forall a. a -> Either TxBodyError a
forall (m :: * -> *) a. Monad m => a -> m a
return (TxBody era -> Either TxBodyError (TxBody era))
-> TxBody era -> Either TxBodyError (TxBody era)
forall a b. (a -> b) -> a -> b
$
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
ShelleyTxBody
ShelleyBasedEra era
sbe
TxBody (ShelleyLedgerEra era)
ConwayTxBody StandardConway
txbody
[Script StandardConway]
[Script (ShelleyLedgerEra era)]
scripts
( AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
forall era.
AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
TxBodyScriptData
AlonzoEraOnwards era
AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway
TxDats StandardConway
TxDats (ShelleyLedgerEra era)
datums
Redeemers StandardConway
Redeemers (ShelleyLedgerEra era)
redeemers
)
Maybe (TxAuxData StandardConway)
Maybe (TxAuxData (ShelleyLedgerEra era))
txAuxData
TxScriptValidity era
txScriptValidity
where
azOn :: AlonzoEraOnwards ConwayEra
azOn = AlonzoEraOnwards ConwayEra
AlonzoEraOnwardsConway
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
witnesses :: [(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
witnesses = ShelleyBasedEra ConwayEra
-> TxBodyContent BuildTx ConwayEra
-> [(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses ShelleyBasedEra era
ShelleyBasedEra ConwayEra
sbe TxBodyContent BuildTx era
TxBodyContent BuildTx ConwayEra
txbodycontent
scripts :: [Ledger.Script StandardConway]
scripts :: [Script StandardConway]
scripts =
[Maybe (AlonzoScript StandardConway)]
-> [AlonzoScript StandardConway]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptInEra ConwayEra -> Script (ShelleyLedgerEra ConwayEra)
ScriptInEra ConwayEra -> AlonzoScript StandardConway
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript (ScriptInEra ConwayEra -> AlonzoScript StandardConway)
-> Maybe (ScriptInEra ConwayEra)
-> Maybe (AlonzoScript StandardConway)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ScriptWitness witctx ConwayEra -> Maybe (ScriptInEra ConwayEra)
forall witctx era.
ScriptWitness witctx era -> Maybe (ScriptInEra era)
getScriptWitnessScript ScriptWitness witctx ConwayEra
scriptwitness
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx ConwayEra
scriptwitness) <- [(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
witnesses
]
datums :: Alonzo.TxDats StandardConway
datums :: TxDats StandardConway
datums =
Map (DataHash (EraCrypto StandardConway)) (Data StandardConway)
-> TxDats StandardConway
forall era.
Era era =>
Map (DataHash (EraCrypto era)) (Data era) -> TxDats era
Alonzo.TxDats (Map (DataHash (EraCrypto StandardConway)) (Data StandardConway)
-> TxDats StandardConway)
-> Map (DataHash (EraCrypto StandardConway)) (Data StandardConway)
-> TxDats StandardConway
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(SafeHash StandardCrypto EraIndependentData)
(Data StandardConway))]
-> Map
(SafeHash StandardCrypto EraIndependentData) (Data StandardConway)
forall l. IsList l => [Item l] -> l
fromList
[ (Data StandardConway -> DataHash (EraCrypto StandardConway)
forall era. Era era => Data era -> DataHash (EraCrypto era)
L.hashData Data StandardConway
d, Data StandardConway
d)
| Data StandardConway
d <- HashableScriptData -> Data StandardConway
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData (HashableScriptData -> Data StandardConway)
-> [HashableScriptData] -> [Data StandardConway]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [HashableScriptData]
scriptdata
]
scriptdata :: [HashableScriptData]
scriptdata :: [HashableScriptData]
scriptdata =
[HashableScriptData
d | TxOut AddressInEra era
_ TxOutValue era
_ (TxOutSupplementalDatum AlonzoEraOnwards era
_ HashableScriptData
d) ReferenceScript era
_ <- [TxOut CtxTx era]
txOuts]
[HashableScriptData]
-> [HashableScriptData] -> [HashableScriptData]
forall a. [a] -> [a] -> [a]
++ [ HashableScriptData
d
| ( ScriptWitnessIndex
_
, AnyScriptWitness
( PlutusScriptWitness
ScriptLanguageInEra lang ConwayEra
_
PlutusScriptVersion lang
_
PlutusScriptOrReferenceInput lang
_
(ScriptDatumForTxIn (Just HashableScriptData
d))
HashableScriptData
_
ExecutionUnits
_
)
) <-
[(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
witnesses
]
redeemers :: Alonzo.Redeemers StandardConway
redeemers :: Redeemers StandardConway
redeemers =
Map
(PlutusPurpose AsIx StandardConway) (Data StandardConway, ExUnits)
-> Redeemers StandardConway
forall era.
AlonzoEraScript era =>
Map (PlutusPurpose AsIx era) (Data era, ExUnits) -> Redeemers era
Alonzo.Redeemers (Map
(PlutusPurpose AsIx StandardConway) (Data StandardConway, ExUnits)
-> Redeemers StandardConway)
-> Map
(PlutusPurpose AsIx StandardConway) (Data StandardConway, ExUnits)
-> Redeemers StandardConway
forall a b. (a -> b) -> a -> b
$
[Item
(Map
(ConwayPlutusPurpose AsIx StandardConway)
(Data StandardConway, ExUnits))]
-> Map
(ConwayPlutusPurpose AsIx StandardConway)
(Data StandardConway, ExUnits)
forall l. IsList l => [Item l] -> l
fromList
[ (ConwayPlutusPurpose AsIx StandardConway
i, (HashableScriptData -> Data StandardConway
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d, ExecutionUnits -> ExUnits
toAlonzoExUnits ExecutionUnits
e))
| ( ScriptWitnessIndex
idx
, AnyScriptWitness
(PlutusScriptWitness ScriptLanguageInEra lang ConwayEra
_ PlutusScriptVersion lang
_ PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
d ExecutionUnits
e)
) <-
[(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
witnesses
, Just ConwayPlutusPurpose AsIx StandardConway
i <- [AlonzoEraOnwards ConwayEra
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall era.
AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra era))
fromScriptWitnessIndex AlonzoEraOnwards ConwayEra
azOn ScriptWitnessIndex
idx]
]
languages :: Set Plutus.Language
languages :: Set Language
languages =
[Item (Set Language)] -> Set Language
forall l. IsList l => [Item l] -> l
fromList ([Item (Set Language)] -> Set Language)
-> [Item (Set Language)] -> Set Language
forall a b. (a -> b) -> a -> b
$
[Maybe Language] -> [Language]
forall a. [Maybe a] -> [a]
catMaybes
[ ScriptWitness witctx era -> Maybe Language
forall witctx. ScriptWitness witctx era -> Maybe Language
getScriptLanguage ScriptWitness witctx era
ScriptWitness witctx ConwayEra
sw
| (ScriptWitnessIndex
_, AnyScriptWitness ScriptWitness witctx ConwayEra
sw) <- [(ScriptWitnessIndex, AnyScriptWitness ConwayEra)]
witnesses
]
getScriptLanguage :: ScriptWitness witctx era -> Maybe Plutus.Language
getScriptLanguage :: forall witctx. ScriptWitness witctx era -> Maybe Language
getScriptLanguage (PlutusScriptWitness ScriptLanguageInEra lang era
_ PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
_ ScriptDatum witctx
_ HashableScriptData
_ 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.
IsPlutusScriptLanguage lang =>
PlutusScriptVersion lang -> AnyPlutusScriptVersion
AnyPlutusScriptVersion PlutusScriptVersion lang
v)
getScriptLanguage SimpleScriptWitness{} = Maybe Language
forall a. Maybe a
Nothing
txAuxData :: Maybe (L.TxAuxData StandardConway)
txAuxData :: Maybe (TxAuxData StandardConway)
txAuxData = ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
txAuxScripts
toShelleyTxOutAny
:: forall ctx era ledgerera
. HasCallStack
=> ShelleyLedgerEra era ~ ledgerera
=> ShelleyBasedEra era
-> TxOut ctx era
-> Ledger.TxOut ledgerera
toShelleyTxOutAny :: forall ctx era ledgerera.
(HasCallStack, ShelleyLedgerEra era ~ ledgerera) =>
ShelleyBasedEra era -> TxOut ctx era -> TxOut ledgerera
toShelleyTxOutAny ShelleyBasedEra era
_ = \case
TxOut AddressInEra era
_ (TxOutValueByron Coin
_) TxOutDatum ctx era
_ ReferenceScript era
_ ->
String -> TxOut ledgerera
forall a. HasCallStack => String -> a
error String
"toShelleyTxOutAny: Expected a Shelley value"
TxOut AddressInEra era
addr (TxOutValueShelleyBased ShelleyBasedEra era
sbe Value (ShelleyLedgerEra era)
value) TxOutDatum ctx era
txoutdata ReferenceScript era
refScript ->
(ShelleyToMaryEraConstraints era =>
ShelleyToMaryEra era -> TxOut ledgerera)
-> (AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era -> TxOut ledgerera)
-> ShelleyBasedEra era
-> TxOut ledgerera
forall era a.
(ShelleyToMaryEraConstraints era => ShelleyToMaryEra era -> a)
-> (AlonzoEraOnwardsConstraints era => AlonzoEraOnwards era -> a)
-> ShelleyBasedEra era
-> a
caseShelleyToMaryOrAlonzoEraOnwards
(TxOut ledgerera -> ShelleyToMaryEra era -> TxOut ledgerera
forall a b. a -> b -> a
const (TxOut ledgerera -> ShelleyToMaryEra era -> TxOut ledgerera)
-> TxOut ledgerera -> ShelleyToMaryEra era -> TxOut ledgerera
forall a b. (a -> b) -> a -> b
$ Addr (EraCrypto ledgerera) -> Value ledgerera -> TxOut ledgerera
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value ledgerera
Value (ShelleyLedgerEra era)
value)
( \case
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo ->
Addr (EraCrypto (AlonzoEra StandardCrypto))
-> Value (AlonzoEra StandardCrypto)
-> TxOut (AlonzoEra StandardCrypto)
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value (AlonzoEra StandardCrypto)
Value (ShelleyLedgerEra era)
value
TxOut (AlonzoEra StandardCrypto)
-> (TxOut (AlonzoEra StandardCrypto) -> TxOut ledgerera)
-> TxOut ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Identity
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))))
-> TxOut (AlonzoEra StandardCrypto)
-> Identity (TxOut (AlonzoEra StandardCrypto))
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Identity
(StrictMaybe (SafeHash StandardCrypto EraIndependentData)))
-> TxOut (AlonzoEra StandardCrypto) -> Identity (TxOut ledgerera)
forall era.
AlonzoEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (DataHash (EraCrypto era)))
Lens'
(TxOut (AlonzoEra StandardCrypto))
(StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto))))
L.dataHashTxOutL ((StrictMaybe (DataHash (EraCrypto (AlonzoEra StandardCrypto)))
-> Identity
(StrictMaybe (SafeHash StandardCrypto EraIndependentData)))
-> TxOut (AlonzoEra StandardCrypto) -> Identity (TxOut ledgerera))
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
-> TxOut (AlonzoEra StandardCrypto)
-> TxOut ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxOutDatum ctx era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
forall ctx era.
TxOutDatum ctx era
-> StrictMaybe (SafeHash StandardCrypto EraIndependentData)
toAlonzoTxOutDatumHash TxOutDatum ctx era
txoutdata
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage ->
Addr (EraCrypto StandardBabbage)
-> Value StandardBabbage -> TxOut StandardBabbage
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value StandardBabbage
Value (ShelleyLedgerEra era)
value
TxOut StandardBabbage
-> (TxOut StandardBabbage -> TxOut StandardBabbage)
-> TxOut StandardBabbage
forall a b. a -> (a -> b) -> b
& (Datum StandardBabbage -> Identity (Datum StandardBabbage))
-> TxOut StandardBabbage -> Identity (TxOut StandardBabbage)
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut StandardBabbage) (Datum StandardBabbage)
L.datumTxOutL ((Datum StandardBabbage -> Identity (Datum StandardBabbage))
-> TxOut StandardBabbage -> Identity (TxOut StandardBabbage))
-> Datum StandardBabbage
-> TxOut StandardBabbage
-> TxOut StandardBabbage
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxOutDatum ctx era -> Datum (ShelleyLedgerEra era)
forall era ctx.
(Era (ShelleyLedgerEra era),
EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum ctx era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum TxOutDatum ctx era
txoutdata
TxOut StandardBabbage
-> (TxOut StandardBabbage -> TxOut ledgerera) -> TxOut ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe (Script StandardBabbage)
-> Identity (StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage -> Identity (TxOut ledgerera)
(StrictMaybe (Script StandardBabbage)
-> Identity (StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage -> Identity (TxOut StandardBabbage)
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens'
(TxOut StandardBabbage) (StrictMaybe (Script StandardBabbage))
L.referenceScriptTxOutL ((StrictMaybe (Script StandardBabbage)
-> Identity (StrictMaybe (Script StandardBabbage)))
-> TxOut StandardBabbage -> Identity (TxOut ledgerera))
-> StrictMaybe (Script StandardBabbage)
-> TxOut StandardBabbage
-> TxOut ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
refScriptToShelleyScript ShelleyBasedEra era
sbe ReferenceScript era
refScript
AlonzoEraOnwards era
AlonzoEraOnwardsConway ->
Addr (EraCrypto StandardConway)
-> Value StandardConway -> TxOut StandardConway
forall era.
(EraTxOut era, HasCallStack) =>
Addr (EraCrypto era) -> Value era -> TxOut era
L.mkBasicTxOut (AddressInEra era -> Addr StandardCrypto
forall era. AddressInEra era -> Addr StandardCrypto
toShelleyAddr AddressInEra era
addr) Value StandardConway
Value (ShelleyLedgerEra era)
value
TxOut StandardConway
-> (TxOut StandardConway -> TxOut StandardConway)
-> TxOut StandardConway
forall a b. a -> (a -> b) -> b
& (Datum StandardConway -> Identity (Datum StandardConway))
-> TxOut StandardConway -> Identity (TxOut StandardConway)
forall era. BabbageEraTxOut era => Lens' (TxOut era) (Datum era)
Lens' (TxOut StandardConway) (Datum StandardConway)
L.datumTxOutL ((Datum StandardConway -> Identity (Datum StandardConway))
-> TxOut StandardConway -> Identity (TxOut StandardConway))
-> Datum StandardConway
-> TxOut StandardConway
-> TxOut StandardConway
forall s t a b. ASetter s t a b -> b -> s -> t
.~ TxOutDatum ctx era -> Datum (ShelleyLedgerEra era)
forall era ctx.
(Era (ShelleyLedgerEra era),
EraCrypto (ShelleyLedgerEra era) ~ StandardCrypto) =>
TxOutDatum ctx era -> Datum (ShelleyLedgerEra era)
toBabbageTxOutDatum TxOutDatum ctx era
txoutdata
TxOut StandardConway
-> (TxOut StandardConway -> TxOut ledgerera) -> TxOut ledgerera
forall a b. a -> (a -> b) -> b
& (StrictMaybe (Script StandardConway)
-> Identity (StrictMaybe (Script StandardConway)))
-> TxOut StandardConway -> Identity (TxOut ledgerera)
(StrictMaybe (Script StandardConway)
-> Identity (StrictMaybe (Script StandardConway)))
-> TxOut StandardConway -> Identity (TxOut StandardConway)
forall era.
BabbageEraTxOut era =>
Lens' (TxOut era) (StrictMaybe (Script era))
Lens' (TxOut StandardConway) (StrictMaybe (Script StandardConway))
L.referenceScriptTxOutL ((StrictMaybe (Script StandardConway)
-> Identity (StrictMaybe (Script StandardConway)))
-> TxOut StandardConway -> Identity (TxOut ledgerera))
-> StrictMaybe (Script StandardConway)
-> TxOut StandardConway
-> TxOut ledgerera
forall s t a b. ASetter s t a b -> b -> s -> t
.~ ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
forall era.
ShelleyBasedEra era
-> ReferenceScript era
-> StrictMaybe (Script (ShelleyLedgerEra era))
refScriptToShelleyScript ShelleyBasedEra era
sbe ReferenceScript era
refScript
)
ShelleyBasedEra era
sbe
data AnyScriptWitness era where
AnyScriptWitness
:: Typeable witctx
=> ScriptWitness witctx era
-> AnyScriptWitness era
deriving instance Show (AnyScriptWitness era)
instance Eq (AnyScriptWitness era) where
AnyScriptWitness ScriptWitness witctx era
sw1 == :: AnyScriptWitness era -> AnyScriptWitness era -> Bool
== AnyScriptWitness ScriptWitness witctx era
sw2 =
case ScriptWitness witctx era
-> ScriptWitness witctx era -> Maybe (witctx :~: witctx)
forall w1 w2.
(Typeable w1, Typeable w2) =>
ScriptWitness w1 era -> ScriptWitness w2 era -> Maybe (w1 :~: w2)
eqsw ScriptWitness witctx era
sw1 ScriptWitness witctx era
sw2 of
Just witctx :~: witctx
Refl -> ScriptWitness witctx era
sw1 ScriptWitness witctx era -> ScriptWitness witctx era -> Bool
forall a. Eq a => a -> a -> Bool
== ScriptWitness witctx era
ScriptWitness witctx era
sw2
Maybe (witctx :~: witctx)
Nothing -> Bool
False
where
eqsw
:: (Typeable w1, Typeable w2)
=> ScriptWitness w1 era
-> ScriptWitness w2 era
-> Maybe (w1 :~: w2)
eqsw :: forall w1 w2.
(Typeable w1, Typeable w2) =>
ScriptWitness w1 era -> ScriptWitness w2 era -> Maybe (w1 :~: w2)
eqsw ScriptWitness w1 era
_ ScriptWitness w2 era
_ = Maybe (w1 :~: w2)
forall {k} (a :: k) (b :: k).
(Typeable a, Typeable b) =>
Maybe (a :~: b)
eqT
data ScriptWitnessIndex
=
ScriptWitnessIndexTxIn !Word32
|
ScriptWitnessIndexMint !Word32
|
ScriptWitnessIndexCertificate !Word32
|
ScriptWitnessIndexWithdrawal !Word32
|
ScriptWitnessIndexVoting !Word32
|
ScriptWitnessIndexProposing !Word32
deriving (ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
(ScriptWitnessIndex -> ScriptWitnessIndex -> Bool)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> Bool)
-> Eq ScriptWitnessIndex
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
== :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
$c/= :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
/= :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
Eq, Eq ScriptWitnessIndex
Eq ScriptWitnessIndex =>
(ScriptWitnessIndex -> ScriptWitnessIndex -> Ordering)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> Bool)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> Bool)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> Bool)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> Bool)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex)
-> (ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex)
-> Ord ScriptWitnessIndex
ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
ScriptWitnessIndex -> ScriptWitnessIndex -> Ordering
ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ScriptWitnessIndex -> ScriptWitnessIndex -> Ordering
compare :: ScriptWitnessIndex -> ScriptWitnessIndex -> Ordering
$c< :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
< :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
$c<= :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
<= :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
$c> :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
> :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
$c>= :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
>= :: ScriptWitnessIndex -> ScriptWitnessIndex -> Bool
$cmax :: ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex
max :: ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex
$cmin :: ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex
min :: ScriptWitnessIndex -> ScriptWitnessIndex -> ScriptWitnessIndex
Ord, Int -> ScriptWitnessIndex -> ShowS
[ScriptWitnessIndex] -> ShowS
ScriptWitnessIndex -> String
(Int -> ScriptWitnessIndex -> ShowS)
-> (ScriptWitnessIndex -> String)
-> ([ScriptWitnessIndex] -> ShowS)
-> Show ScriptWitnessIndex
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptWitnessIndex -> ShowS
showsPrec :: Int -> ScriptWitnessIndex -> ShowS
$cshow :: ScriptWitnessIndex -> String
show :: ScriptWitnessIndex -> String
$cshowList :: [ScriptWitnessIndex] -> ShowS
showList :: [ScriptWitnessIndex] -> ShowS
Show)
instance ToJSON ScriptWitnessIndex where
toJSON :: ScriptWitnessIndex -> Value
toJSON = \case
ScriptWitnessIndexTxIn Word32
n ->
[Pair] -> Value
object
[ Key
"kind" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"ScriptWitnessIndexTxIn"
, Key
"value" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word32
n
]
ScriptWitnessIndexMint Word32
n ->
[Pair] -> Value
object
[ Key
"kind" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"ScriptWitnessIndexMint"
, Key
"value" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word32
n
]
ScriptWitnessIndexCertificate Word32
n ->
[Pair] -> Value
object
[ Key
"kind" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"ScriptWitnessIndexCertificate"
, Key
"value" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word32
n
]
ScriptWitnessIndexWithdrawal Word32
n ->
[Pair] -> Value
object
[ Key
"kind" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"ScriptWitnessIndexWithdrawal"
, Key
"value" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word32
n
]
ScriptWitnessIndexVoting Word32
n ->
[Pair] -> Value
object
[ Key
"kind" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"ScriptWitnessIndexVoting"
, Key
"value" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word32
n
]
ScriptWitnessIndexProposing Word32
n ->
[Pair] -> Value
object
[ Key
"kind" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
Aeson.String Text
"ScriptWitnessIndexProposing"
, Key
"value" Key -> Word32 -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Word32
n
]
renderScriptWitnessIndex :: ScriptWitnessIndex -> String
renderScriptWitnessIndex :: ScriptWitnessIndex -> String
renderScriptWitnessIndex (ScriptWitnessIndexTxIn Word32
index) =
String
"transaction input " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word32 -> String
forall a. Show a => a -> String
show Word32
index String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (in ascending order of the TxIds)"
renderScriptWitnessIndex (ScriptWitnessIndexMint Word32
index) =
String
"policyId " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word32 -> String
forall a. Show a => a -> String
show Word32
index String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (in ascending order of the PolicyIds)"
renderScriptWitnessIndex (ScriptWitnessIndexCertificate Word32
index) =
String
"certificate " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word32 -> String
forall a. Show a => a -> String
show Word32
index String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (in the list order of the certificates)"
renderScriptWitnessIndex (ScriptWitnessIndexWithdrawal Word32
index) =
String
"withdrawal " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word32 -> String
forall a. Show a => a -> String
show Word32
index String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (in ascending order of the StakeAddresses)"
renderScriptWitnessIndex (ScriptWitnessIndexVoting Word32
index) =
String
"vote " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word32 -> String
forall a. Show a => a -> String
show Word32
index String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (in ascending order of the votes)"
renderScriptWitnessIndex (ScriptWitnessIndexProposing Word32
index) =
String
"proposal " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Word32 -> String
forall a. Show a => a -> String
show Word32
index String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" (in ascending order of the proposals)"
fromScriptWitnessIndex
:: AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (L.PlutusPurpose L.AsIx (ShelleyLedgerEra era))
fromScriptWitnessIndex :: forall era.
AlonzoEraOnwards era
-> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra era))
fromScriptWitnessIndex AlonzoEraOnwards era
aOnwards ScriptWitnessIndex
widx =
case AlonzoEraOnwards era
aOnwards of
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo -> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
fromScriptWitnessIndexAlonzo ScriptWitnessIndex
widx
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage -> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
fromScriptWitnessIndexBabbage ScriptWitnessIndex
widx
AlonzoEraOnwards era
AlonzoEraOnwardsConway -> ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
fromScriptWitnessIndexConway ScriptWitnessIndex
widx
fromScriptWitnessIndexAlonzo
:: ScriptWitnessIndex -> Maybe (L.PlutusPurpose L.AsIx (ShelleyLedgerEra AlonzoEra))
fromScriptWitnessIndexAlonzo :: ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
fromScriptWitnessIndexAlonzo ScriptWitnessIndex
i =
case ScriptWitnessIndex
i of
ScriptWitnessIndexTxIn Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (TxIn (EraCrypto (AlonzoEra StandardCrypto)))
-> AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto)
forall (f :: * -> * -> *) era.
f Word32 (TxIn (EraCrypto era)) -> AlonzoPlutusPurpose f era
L.AlonzoSpending (Word32 -> AsIx Word32 (TxIn StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexMint Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (PolicyID (EraCrypto (AlonzoEra StandardCrypto)))
-> AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto)
forall (f :: * -> * -> *) era.
f Word32 (PolicyID (EraCrypto era)) -> AlonzoPlutusPurpose f era
L.AlonzoMinting (Word32 -> AsIx Word32 (PolicyID StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexCertificate Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (TxCert (AlonzoEra StandardCrypto))
-> AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto)
forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> AlonzoPlutusPurpose f era
L.AlonzoCertifying (Word32 -> AsIx Word32 (ShelleyTxCert (AlonzoEra StandardCrypto))
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexWithdrawal Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (RewardAccount (EraCrypto (AlonzoEra StandardCrypto)))
-> AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto)
forall (f :: * -> * -> *) era.
f Word32 (RewardAccount (EraCrypto era))
-> AlonzoPlutusPurpose f era
L.AlonzoRewarding (Word32 -> AsIx Word32 (RewardAccount StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndex
_ -> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra))
Maybe (AlonzoPlutusPurpose AsIx (AlonzoEra StandardCrypto))
forall a. Maybe a
Nothing
fromScriptWitnessIndexBabbage
:: ScriptWitnessIndex -> Maybe (L.PlutusPurpose L.AsIx (ShelleyLedgerEra BabbageEra))
fromScriptWitnessIndexBabbage :: ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
fromScriptWitnessIndexBabbage ScriptWitnessIndex
i =
case ScriptWitnessIndex
i of
ScriptWitnessIndexTxIn Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (TxIn (EraCrypto StandardBabbage))
-> AlonzoPlutusPurpose AsIx StandardBabbage
forall (f :: * -> * -> *) era.
f Word32 (TxIn (EraCrypto era)) -> AlonzoPlutusPurpose f era
L.AlonzoSpending (Word32 -> AsIx Word32 (TxIn StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexMint Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (PolicyID (EraCrypto StandardBabbage))
-> AlonzoPlutusPurpose AsIx StandardBabbage
forall (f :: * -> * -> *) era.
f Word32 (PolicyID (EraCrypto era)) -> AlonzoPlutusPurpose f era
L.AlonzoMinting (Word32 -> AsIx Word32 (PolicyID StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexCertificate Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (TxCert StandardBabbage)
-> AlonzoPlutusPurpose AsIx StandardBabbage
forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> AlonzoPlutusPurpose f era
L.AlonzoCertifying (Word32 -> AsIx Word32 (ShelleyTxCert StandardBabbage)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexWithdrawal Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (RewardAccount (EraCrypto StandardBabbage))
-> AlonzoPlutusPurpose AsIx StandardBabbage
forall (f :: * -> * -> *) era.
f Word32 (RewardAccount (EraCrypto era))
-> AlonzoPlutusPurpose f era
L.AlonzoRewarding (Word32 -> AsIx Word32 (RewardAccount StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndex
_ -> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra BabbageEra))
Maybe (AlonzoPlutusPurpose AsIx StandardBabbage)
forall a. Maybe a
Nothing
fromScriptWitnessIndexConway
:: ScriptWitnessIndex -> Maybe (L.PlutusPurpose L.AsIx (ShelleyLedgerEra ConwayEra))
fromScriptWitnessIndexConway :: ScriptWitnessIndex
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
fromScriptWitnessIndexConway ScriptWitnessIndex
i =
case ScriptWitnessIndex
i of
ScriptWitnessIndexTxIn Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (TxIn (EraCrypto StandardConway))
-> ConwayPlutusPurpose AsIx StandardConway
forall (f :: * -> * -> *) era.
f Word32 (TxIn (EraCrypto era)) -> ConwayPlutusPurpose f era
L.ConwaySpending (Word32 -> AsIx Word32 (TxIn StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexMint Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (PolicyID (EraCrypto StandardConway))
-> ConwayPlutusPurpose AsIx StandardConway
forall (f :: * -> * -> *) era.
f Word32 (PolicyID (EraCrypto era)) -> ConwayPlutusPurpose f era
L.ConwayMinting (Word32 -> AsIx Word32 (PolicyID StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexCertificate Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (TxCert StandardConway)
-> ConwayPlutusPurpose AsIx StandardConway
forall (f :: * -> * -> *) era.
f Word32 (TxCert era) -> ConwayPlutusPurpose f era
L.ConwayCertifying (Word32 -> AsIx Word32 (ConwayTxCert StandardConway)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexWithdrawal Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (RewardAccount (EraCrypto StandardConway))
-> ConwayPlutusPurpose AsIx StandardConway
forall (f :: * -> * -> *) era.
f Word32 (RewardAccount (EraCrypto era))
-> ConwayPlutusPurpose f era
L.ConwayRewarding (Word32 -> AsIx Word32 (RewardAccount StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexVoting Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (Voter (EraCrypto StandardConway))
-> ConwayPlutusPurpose AsIx StandardConway
forall (f :: * -> * -> *) era.
f Word32 (Voter (EraCrypto era)) -> ConwayPlutusPurpose f era
L.ConwayVoting (Word32 -> AsIx Word32 (Voter StandardCrypto)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
ScriptWitnessIndexProposing Word32
n -> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a. a -> Maybe a
Just (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)))
-> PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> Maybe (PlutusPurpose AsIx (ShelleyLedgerEra ConwayEra))
forall a b. (a -> b) -> a -> b
$ AsIx Word32 (ProposalProcedure StandardConway)
-> ConwayPlutusPurpose AsIx StandardConway
forall (f :: * -> * -> *) era.
f Word32 (ProposalProcedure era) -> ConwayPlutusPurpose f era
L.ConwayProposing (Word32 -> AsIx Word32 (ProposalProcedure StandardConway)
forall ix it. ix -> AsIx ix it
L.AsIx Word32
n)
toScriptIndex
:: AlonzoEraOnwards era
-> L.PlutusPurpose L.AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndex :: forall era.
AlonzoEraOnwards era
-> PlutusPurpose AsIx (ShelleyLedgerEra era) -> ScriptWitnessIndex
toScriptIndex AlonzoEraOnwards era
sbe PlutusPurpose AsIx (ShelleyLedgerEra era)
scriptPurposeIndex =
case AlonzoEraOnwards era
sbe of
AlonzoEraOnwards era
AlonzoEraOnwardsAlonzo -> AlonzoPlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
-> ScriptWitnessIndex
forall era.
AlonzoPlutusPurpose AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexAlonzo PlutusPurpose AsIx (ShelleyLedgerEra era)
AlonzoPlutusPurpose AsIx (ShelleyLedgerEra AlonzoEra)
scriptPurposeIndex
AlonzoEraOnwards era
AlonzoEraOnwardsBabbage -> AlonzoPlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
-> ScriptWitnessIndex
forall era.
AlonzoPlutusPurpose AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexAlonzo PlutusPurpose AsIx (ShelleyLedgerEra era)
AlonzoPlutusPurpose AsIx (ShelleyLedgerEra BabbageEra)
scriptPurposeIndex
AlonzoEraOnwards era
AlonzoEraOnwardsConway -> ConwayPlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
-> ScriptWitnessIndex
forall era.
ConwayPlutusPurpose AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexConway PlutusPurpose AsIx (ShelleyLedgerEra era)
ConwayPlutusPurpose AsIx (ShelleyLedgerEra ConwayEra)
scriptPurposeIndex
toScriptIndexAlonzo
:: L.AlonzoPlutusPurpose L.AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexAlonzo :: forall era.
AlonzoPlutusPurpose AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexAlonzo AlonzoPlutusPurpose AsIx (ShelleyLedgerEra era)
scriptPurposeIndex =
case AlonzoPlutusPurpose AsIx (ShelleyLedgerEra era)
scriptPurposeIndex of
L.AlonzoSpending (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexTxIn Word32
i
L.AlonzoMinting (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexMint Word32
i
L.AlonzoCertifying (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexCertificate Word32
i
L.AlonzoRewarding (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexWithdrawal Word32
i
toScriptIndexConway
:: L.ConwayPlutusPurpose L.AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexConway :: forall era.
ConwayPlutusPurpose AsIx (ShelleyLedgerEra era)
-> ScriptWitnessIndex
toScriptIndexConway ConwayPlutusPurpose AsIx (ShelleyLedgerEra era)
scriptPurposeIndex =
case ConwayPlutusPurpose AsIx (ShelleyLedgerEra era)
scriptPurposeIndex of
L.ConwaySpending (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexTxIn Word32
i
L.ConwayMinting (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexMint Word32
i
L.ConwayCertifying (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexCertificate Word32
i
L.ConwayRewarding (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexWithdrawal Word32
i
L.ConwayVoting (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexVoting Word32
i
L.ConwayProposing (L.AsIx Word32
i) -> Word32 -> ScriptWitnessIndex
ScriptWitnessIndexProposing Word32
i
collectTxBodyScriptWitnesses
:: forall era
. ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses :: forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
collectTxBodyScriptWitnesses
ShelleyBasedEra era
_
TxBodyContent
{ TxIns BuildTx era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txIns :: TxIns BuildTx era
txIns
, TxWithdrawals BuildTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txWithdrawals :: TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txCertificates :: TxCertificates BuildTx era
txCertificates
, TxMintValue BuildTx era
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMintValue :: TxMintValue BuildTx era
txMintValue
, Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures :: forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures build era))
txVotingProcedures :: Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures
, Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures :: forall build era.
TxBodyContent build era
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures build era))
txProposalProcedures :: Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures
} =
[[(ScriptWitnessIndex, AnyScriptWitness era)]]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
concat
[ TxIns BuildTx era -> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesTxIns TxIns BuildTx era
txIns
, TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesWithdrawals TxWithdrawals BuildTx era
txWithdrawals
, TxCertificates BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesCertificates TxCertificates BuildTx era
txCertificates
, TxMintValue BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesMinting TxMintValue BuildTx era
txMintValue
, TxVotingProcedures BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesVoting (TxVotingProcedures BuildTx era
-> (Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era)
-> TxVotingProcedures BuildTx era)
-> Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
-> TxVotingProcedures BuildTx era
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TxVotingProcedures BuildTx era
forall build era. TxVotingProcedures build era
TxVotingProceduresNone Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era)
-> TxVotingProcedures BuildTx era
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured Maybe
(Featured ConwayEraOnwards era (TxVotingProcedures BuildTx era))
txVotingProcedures)
, TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesProposing (TxProposalProcedures BuildTx era
-> (Featured
ConwayEraOnwards era (TxProposalProcedures BuildTx era)
-> TxProposalProcedures BuildTx era)
-> Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
-> TxProposalProcedures BuildTx era
forall b a. b -> (a -> b) -> Maybe a -> b
maybe TxProposalProcedures BuildTx era
forall build era. TxProposalProcedures build era
TxProposalProceduresNone Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era)
-> TxProposalProcedures BuildTx era
forall (eon :: * -> *) era a. Featured eon era a -> a
unFeatured Maybe
(Featured ConwayEraOnwards era (TxProposalProcedures BuildTx era))
txProposalProcedures)
]
where
scriptWitnessesTxIns
:: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn era))]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesTxIns :: TxIns BuildTx era -> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesTxIns TxIns BuildTx era
txIns' =
[(ScriptWitnessIndex, AnyScriptWitness era)]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall a. Eq a => [a] -> [a]
List.nub
[ (ScriptWitnessIndex
ix, ScriptWitness WitCtxTxIn era -> AnyScriptWitness era
forall witctx era.
Typeable witctx =>
ScriptWitness witctx era -> AnyScriptWitness era
AnyScriptWitness ScriptWitness WitCtxTxIn era
witness)
| (ScriptWitnessIndex
ix, TxIn
_, ScriptWitness ScriptWitnessInCtx WitCtxTxIn
_ ScriptWitness WitCtxTxIn era
witness) <- TxIns BuildTx era
-> [(ScriptWitnessIndex, TxIn, Witness WitCtxTxIn era)]
forall era.
TxIns BuildTx era
-> [(ScriptWitnessIndex, TxIn, Witness WitCtxTxIn era)]
indexTxIns TxIns BuildTx era
txIns'
]
scriptWitnessesWithdrawals
:: TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesWithdrawals :: TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesWithdrawals TxWithdrawals BuildTx era
TxWithdrawalsNone = []
scriptWitnessesWithdrawals TxWithdrawals BuildTx era
txw =
[(ScriptWitnessIndex, AnyScriptWitness era)]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall a. Eq a => [a] -> [a]
List.nub
[ (ScriptWitnessIndex
ix, ScriptWitness WitCtxStake era -> AnyScriptWitness era
forall witctx era.
Typeable witctx =>
ScriptWitness witctx era -> AnyScriptWitness era
AnyScriptWitness ScriptWitness WitCtxStake era
witness)
| (ScriptWitnessIndex
ix, StakeAddress
_, Coin
_, ScriptWitness ScriptWitnessInCtx WitCtxStake
_ ScriptWitness WitCtxStake era
witness) <- TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, StakeAddress, Coin,
Witness WitCtxStake era)]
forall era.
TxWithdrawals BuildTx era
-> [(ScriptWitnessIndex, StakeAddress, Coin,
Witness WitCtxStake era)]
indexTxWithdrawals TxWithdrawals BuildTx era
txw
]
scriptWitnessesCertificates
:: TxCertificates BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesCertificates :: TxCertificates BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesCertificates TxCertificates BuildTx era
TxCertificatesNone = []
scriptWitnessesCertificates TxCertificates BuildTx era
txc =
[(ScriptWitnessIndex, AnyScriptWitness era)]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall a. Eq a => [a] -> [a]
List.nub
[ (ScriptWitnessIndex
ix, ScriptWitness WitCtxStake era -> AnyScriptWitness era
forall witctx era.
Typeable witctx =>
ScriptWitness witctx era -> AnyScriptWitness era
AnyScriptWitness ScriptWitness WitCtxStake era
witness)
| (ScriptWitnessIndex
ix, Certificate era
_, StakeCredential
_, ScriptWitness ScriptWitnessInCtx WitCtxStake
_ ScriptWitness WitCtxStake era
witness) <- TxCertificates BuildTx era
-> [(ScriptWitnessIndex, Certificate era, StakeCredential,
Witness WitCtxStake era)]
forall era.
TxCertificates BuildTx era
-> [(ScriptWitnessIndex, Certificate era, StakeCredential,
Witness WitCtxStake era)]
indexTxCertificates TxCertificates BuildTx era
txc
]
scriptWitnessesMinting
:: TxMintValue BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesMinting :: TxMintValue BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesMinting TxMintValue BuildTx era
TxMintNone = []
scriptWitnessesMinting TxMintValue BuildTx era
txMintValue' =
[(ScriptWitnessIndex, AnyScriptWitness era)]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall a. Eq a => [a] -> [a]
List.nub
[ (ScriptWitnessIndex
ix, ScriptWitness WitCtxMint era -> AnyScriptWitness era
forall witctx era.
Typeable witctx =>
ScriptWitness witctx era -> AnyScriptWitness era
AnyScriptWitness ScriptWitness WitCtxMint era
witness)
| (ScriptWitnessIndex
ix, PolicyId
_, AssetName
_, Quantity
_, BuildTxWith ScriptWitness WitCtxMint era
witness) <- TxMintValue BuildTx era
-> [(ScriptWitnessIndex, PolicyId, AssetName, Quantity,
BuildTxWith BuildTx (ScriptWitness WitCtxMint era))]
forall build era.
TxMintValue build era
-> [(ScriptWitnessIndex, PolicyId, AssetName, Quantity,
BuildTxWith build (ScriptWitness WitCtxMint era))]
indexTxMintValue TxMintValue BuildTx era
txMintValue'
]
scriptWitnessesVoting
:: TxVotingProcedures BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesVoting :: TxVotingProcedures BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesVoting TxVotingProcedures BuildTx era
TxVotingProceduresNone = []
scriptWitnessesVoting TxVotingProcedures BuildTx era
txv =
[(ScriptWitnessIndex, AnyScriptWitness era)]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall a. Eq a => [a] -> [a]
List.nub
[ (ScriptWitnessIndex
ix, ScriptWitness WitCtxStake era -> AnyScriptWitness era
forall witctx era.
Typeable witctx =>
ScriptWitness witctx era -> AnyScriptWitness era
AnyScriptWitness ScriptWitness WitCtxStake era
witness)
| (ScriptWitnessIndex
ix, Voter (EraCrypto (ShelleyLedgerEra era))
_, ScriptWitness WitCtxStake era
witness) <- TxVotingProcedures BuildTx era
-> [(ScriptWitnessIndex, Voter (EraCrypto (ShelleyLedgerEra era)),
ScriptWitness WitCtxStake era)]
forall era.
TxVotingProcedures BuildTx era
-> [(ScriptWitnessIndex, Voter (EraCrypto (ShelleyLedgerEra era)),
ScriptWitness WitCtxStake era)]
indexTxVotingProcedures TxVotingProcedures BuildTx era
txv
]
scriptWitnessesProposing
:: TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesProposing :: TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
scriptWitnessesProposing TxProposalProcedures BuildTx era
TxProposalProceduresNone = []
scriptWitnessesProposing TxProposalProcedures BuildTx era
txp =
[(ScriptWitnessIndex, AnyScriptWitness era)]
-> [(ScriptWitnessIndex, AnyScriptWitness era)]
forall a. Eq a => [a] -> [a]
List.nub
[ (ScriptWitnessIndex
ix, ScriptWitness WitCtxStake era -> AnyScriptWitness era
forall witctx era.
Typeable witctx =>
ScriptWitness witctx era -> AnyScriptWitness era
AnyScriptWitness ScriptWitness WitCtxStake era
witness)
| (ScriptWitnessIndex
ix, ProposalProcedure (ShelleyLedgerEra era)
_, ScriptWitness WitCtxStake era
witness) <- TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]
forall era.
TxProposalProcedures BuildTx era
-> [(ScriptWitnessIndex, ProposalProcedure (ShelleyLedgerEra era),
ScriptWitness WitCtxStake era)]
indexTxProposalProcedures TxProposalProcedures BuildTx era
txp
]
toShelleyWithdrawal :: [(StakeAddress, L.Coin, a)] -> L.Withdrawals StandardCrypto
toShelleyWithdrawal :: forall a. [(StakeAddress, Coin, a)] -> Withdrawals StandardCrypto
toShelleyWithdrawal [(StakeAddress, Coin, a)]
withdrawals =
Map (RewardAccount StandardCrypto) Coin
-> Withdrawals StandardCrypto
forall c. Map (RewardAccount c) Coin -> Withdrawals c
L.Withdrawals (Map (RewardAccount StandardCrypto) Coin
-> Withdrawals StandardCrypto)
-> Map (RewardAccount StandardCrypto) Coin
-> Withdrawals StandardCrypto
forall a b. (a -> b) -> a -> b
$
[Item (Map (RewardAccount StandardCrypto) Coin)]
-> Map (RewardAccount StandardCrypto) Coin
forall l. IsList l => [Item l] -> l
fromList
[ (StakeAddress -> RewardAccount StandardCrypto
toShelleyStakeAddr StakeAddress
stakeAddr, Coin
value)
| (StakeAddress
stakeAddr, Coin
value, a
_) <- [(StakeAddress, Coin, a)]
withdrawals
]
fromShelleyWithdrawal
:: L.Withdrawals StandardCrypto
-> [(StakeAddress, L.Coin, BuildTxWith ViewTx (Witness WitCtxStake era))]
fromShelleyWithdrawal :: forall era.
Withdrawals StandardCrypto
-> [(StakeAddress, Coin,
BuildTxWith ViewTx (Witness WitCtxStake era))]
fromShelleyWithdrawal (L.Withdrawals Map (RewardAccount StandardCrypto) Coin
withdrawals) =
[ (RewardAccount StandardCrypto -> StakeAddress
fromShelleyStakeAddr RewardAccount StandardCrypto
stakeAddr, Coin
value, BuildTxWith ViewTx (Witness WitCtxStake era)
forall a. BuildTxWith ViewTx a
ViewTx)
| (RewardAccount StandardCrypto
stakeAddr, Coin
value) <- Map (RewardAccount StandardCrypto) Coin
-> [(RewardAccount StandardCrypto, Coin)]
forall k a. Map k a -> [(k, a)]
Map.assocs Map (RewardAccount StandardCrypto) Coin
withdrawals
]
toAuxiliaryData
:: ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (L.TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData :: forall era.
ShelleyBasedEra era
-> TxMetadataInEra era
-> TxAuxScripts era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
toAuxiliaryData ShelleyBasedEra era
sbe TxMetadataInEra era
txMetadata TxAuxScripts era
txAuxScripts =
let ms :: Map Word64 Metadatum
ms = case TxMetadataInEra era
txMetadata of
TxMetadataInEra era
TxMetadataNone -> Map Word64 Metadatum
forall k a. Map k a
Map.empty
TxMetadataInEra ShelleyBasedEra era
_ (TxMetadata Map Word64 TxMetadataValue
ms') -> Map Word64 TxMetadataValue -> Map Word64 Metadatum
toShelleyMetadata Map Word64 TxMetadataValue
ms'
ss :: [Script (ShelleyLedgerEra era)]
ss = case TxAuxScripts era
txAuxScripts of
TxAuxScripts era
TxAuxScriptsNone -> []
TxAuxScripts AllegraEraOnwards era
_ [ScriptInEra era]
ss' -> (ScriptInEra era -> Script (ShelleyLedgerEra era))
-> [ScriptInEra era] -> [Script (ShelleyLedgerEra era)]
forall a b. (a -> b) -> [a] -> [b]
map ScriptInEra era -> Script (ShelleyLedgerEra era)
forall era. ScriptInEra era -> Script (ShelleyLedgerEra era)
toShelleyScript [ScriptInEra era]
ss'
in case ShelleyBasedEra era
sbe of
ShelleyBasedEra era
ShelleyBasedEraShelley ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Map Word64 Metadatum -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 Metadatum
ms)) Maybe ()
-> ShelleyTxAuxData (ShelleyEra StandardCrypto)
-> Maybe (ShelleyTxAuxData (ShelleyEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Map Word64 Metadatum
-> ShelleyTxAuxData (ShelleyEra StandardCrypto)
forall era. Era era => Map Word64 Metadatum -> ShelleyTxAuxData era
L.ShelleyTxAuxData Map Word64 Metadatum
ms
ShelleyBasedEra era
ShelleyBasedEraAllegra ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Map Word64 Metadatum -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 Metadatum
ms Bool -> Bool -> Bool
&& [Script (ShelleyLedgerEra era)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Script (ShelleyLedgerEra era)]
ss)) Maybe ()
-> AllegraTxAuxData (AllegraEra StandardCrypto)
-> Maybe (AllegraTxAuxData (AllegraEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Map Word64 Metadatum
-> StrictSeq (Timelock (AllegraEra StandardCrypto))
-> AllegraTxAuxData (AllegraEra StandardCrypto)
forall era.
Era era =>
Map Word64 Metadatum
-> StrictSeq (Timelock era) -> AllegraTxAuxData era
L.AllegraTxAuxData Map Word64 Metadatum
ms ([Item (StrictSeq (Timelock (AllegraEra StandardCrypto)))]
-> StrictSeq (Timelock (AllegraEra StandardCrypto))
forall l. IsList l => [Item l] -> l
fromList [Item (StrictSeq (Timelock (AllegraEra StandardCrypto)))]
[Script (ShelleyLedgerEra era)]
ss)
ShelleyBasedEra era
ShelleyBasedEraMary ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Map Word64 Metadatum -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 Metadatum
ms Bool -> Bool -> Bool
&& [Script (ShelleyLedgerEra era)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Script (ShelleyLedgerEra era)]
ss)) Maybe ()
-> AllegraTxAuxData (MaryEra StandardCrypto)
-> Maybe (AllegraTxAuxData (MaryEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Map Word64 Metadatum
-> StrictSeq (Timelock (MaryEra StandardCrypto))
-> AllegraTxAuxData (MaryEra StandardCrypto)
forall era.
Era era =>
Map Word64 Metadatum
-> StrictSeq (Timelock era) -> AllegraTxAuxData era
L.AllegraTxAuxData Map Word64 Metadatum
ms ([Item (StrictSeq (Timelock (MaryEra StandardCrypto)))]
-> StrictSeq (Timelock (MaryEra StandardCrypto))
forall l. IsList l => [Item l] -> l
fromList [Item (StrictSeq (Timelock (MaryEra StandardCrypto)))]
[Script (ShelleyLedgerEra era)]
ss)
ShelleyBasedEra era
ShelleyBasedEraAlonzo ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Map Word64 Metadatum -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 Metadatum
ms Bool -> Bool -> Bool
&& [Script (ShelleyLedgerEra era)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Script (ShelleyLedgerEra era)]
ss)) Maybe ()
-> AlonzoTxAuxData (AlonzoEra StandardCrypto)
-> Maybe (AlonzoTxAuxData (AlonzoEra StandardCrypto))
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Map Word64 Metadatum
-> [AlonzoScript (AlonzoEra StandardCrypto)]
-> AlonzoTxAuxData (AlonzoEra StandardCrypto)
forall (f :: * -> *) era.
(Foldable f, AlonzoEraScript era) =>
Map Word64 Metadatum -> f (AlonzoScript era) -> AlonzoTxAuxData era
L.mkAlonzoTxAuxData Map Word64 Metadatum
ms [Script (ShelleyLedgerEra era)]
[AlonzoScript (AlonzoEra StandardCrypto)]
ss
ShelleyBasedEra era
ShelleyBasedEraBabbage ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Map Word64 Metadatum -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 Metadatum
ms Bool -> Bool -> Bool
&& [Script (ShelleyLedgerEra era)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Script (ShelleyLedgerEra era)]
ss)) Maybe ()
-> AlonzoTxAuxData StandardBabbage
-> Maybe (AlonzoTxAuxData StandardBabbage)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Map Word64 Metadatum
-> [AlonzoScript StandardBabbage]
-> AlonzoTxAuxData StandardBabbage
forall (f :: * -> *) era.
(Foldable f, AlonzoEraScript era) =>
Map Word64 Metadatum -> f (AlonzoScript era) -> AlonzoTxAuxData era
L.mkAlonzoTxAuxData Map Word64 Metadatum
ms [Script (ShelleyLedgerEra era)]
[AlonzoScript StandardBabbage]
ss
ShelleyBasedEra era
ShelleyBasedEraConway ->
Bool -> Maybe ()
forall (f :: * -> *). Alternative f => Bool -> f ()
guard (Bool -> Bool
not (Map Word64 Metadatum -> Bool
forall k a. Map k a -> Bool
Map.null Map Word64 Metadatum
ms Bool -> Bool -> Bool
&& [Script (ShelleyLedgerEra era)] -> Bool
forall a. [a] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Script (ShelleyLedgerEra era)]
ss)) Maybe ()
-> AlonzoTxAuxData StandardConway
-> Maybe (AlonzoTxAuxData StandardConway)
forall (f :: * -> *) a b. Functor f => f a -> b -> f b
$> Map Word64 Metadatum
-> [AlonzoScript StandardConway] -> AlonzoTxAuxData StandardConway
forall (f :: * -> *) era.
(Foldable f, AlonzoEraScript era) =>
Map Word64 Metadatum -> f (AlonzoScript era) -> AlonzoTxAuxData era
L.mkAlonzoTxAuxData Map Word64 Metadatum
ms [Script (ShelleyLedgerEra era)]
[AlonzoScript StandardConway]
ss
genesisUTxOPseudoTxIn :: NetworkId -> Hash GenesisUTxOKey -> TxIn
genesisUTxOPseudoTxIn :: NetworkId -> Hash GenesisUTxOKey -> TxIn
genesisUTxOPseudoTxIn NetworkId
nw (GenesisUTxOKeyHash KeyHash 'Payment StandardCrypto
kh) =
TxIn StandardCrypto -> TxIn
fromShelleyTxIn (Addr StandardCrypto -> TxIn StandardCrypto
forall c. Crypto c => Addr c -> TxIn c
Shelley.initialFundsPseudoTxIn Addr StandardCrypto
addr)
where
addr :: L.Addr StandardCrypto
addr :: Addr StandardCrypto
addr =
Network
-> PaymentCredential StandardCrypto
-> StakeReference StandardCrypto
-> Addr StandardCrypto
forall c.
Network -> PaymentCredential c -> StakeReference c -> Addr c
L.Addr
(NetworkId -> Network
toShelleyNetwork NetworkId
nw)
(KeyHash 'Payment StandardCrypto -> PaymentCredential StandardCrypto
forall (kr :: KeyRole) c. KeyHash kr c -> Credential kr c
Shelley.KeyHashObj KeyHash 'Payment StandardCrypto
kh)
StakeReference StandardCrypto
forall c. StakeReference c
Shelley.StakeRefNull
getReferenceInputsSizeForTxIds
:: ShelleyLedgerEra era ~ ledgerera
=> BabbageEraOnwards era
-> Ledger.UTxO ledgerera
-> Set TxIn
-> Int
getReferenceInputsSizeForTxIds :: forall era ledgerera.
(ShelleyLedgerEra era ~ ledgerera) =>
BabbageEraOnwards era -> UTxO ledgerera -> Set TxIn -> Int
getReferenceInputsSizeForTxIds BabbageEraOnwards era
beo UTxO ledgerera
utxo Set TxIn
txIds = BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => Int) -> Int
forall era a.
BabbageEraOnwards era
-> (BabbageEraOnwardsConstraints era => a) -> a
babbageEraOnwardsConstraints BabbageEraOnwards era
beo ((BabbageEraOnwardsConstraints era => Int) -> Int)
-> (BabbageEraOnwardsConstraints era => Int) -> Int
forall a b. (a -> b) -> a -> b
$ do
let refScripts :: [(ScriptHash (EraCrypto ledgerera), Script ledgerera)]
refScripts = UTxO ledgerera
-> Set (TxIn (EraCrypto ledgerera))
-> [(ScriptHash (EraCrypto ledgerera), Script ledgerera)]
forall era.
BabbageEraTxOut era =>
UTxO era
-> Set (TxIn (EraCrypto era))
-> [(ScriptHash (EraCrypto era), Script era)]
L.getReferenceScriptsNonDistinct UTxO ledgerera
utxo ((TxIn -> TxIn StandardCrypto)
-> Set TxIn -> Set (TxIn StandardCrypto)
forall b a. Ord b => (a -> b) -> Set a -> Set b
Set.map TxIn -> TxIn StandardCrypto
toShelleyTxIn Set TxIn
txIds)
Sum Int -> Int
forall a. Sum a -> a
getSum (Sum Int -> Int) -> Sum Int -> Int
forall a b. (a -> b) -> a -> b
$ ((ScriptHash StandardCrypto, AlonzoScript ledgerera) -> Sum Int)
-> [(ScriptHash StandardCrypto, AlonzoScript ledgerera)] -> Sum Int
forall m a. Monoid m => (a -> m) -> [a] -> m
forall (t :: * -> *) m a.
(Foldable t, Monoid m) =>
(a -> m) -> t a -> m
foldMap (Int -> Sum Int
forall a. a -> Sum a
Sum (Int -> Sum Int)
-> ((ScriptHash StandardCrypto, AlonzoScript ledgerera) -> Int)
-> (ScriptHash StandardCrypto, AlonzoScript ledgerera)
-> Sum Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. AlonzoScript ledgerera -> Int
forall t. SafeToHash t => t -> Int
SafeHash.originalBytesSize (AlonzoScript ledgerera -> Int)
-> ((ScriptHash StandardCrypto, AlonzoScript ledgerera)
-> AlonzoScript ledgerera)
-> (ScriptHash StandardCrypto, AlonzoScript ledgerera)
-> Int
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (ScriptHash StandardCrypto, AlonzoScript ledgerera)
-> AlonzoScript ledgerera
forall a b. (a, b) -> b
snd) [(ScriptHash (EraCrypto ledgerera), Script ledgerera)]
[(ScriptHash StandardCrypto, AlonzoScript ledgerera)]
refScripts
calculateExecutionUnitsLovelace :: Ledger.Prices -> ExecutionUnits -> Maybe L.Coin
calculateExecutionUnitsLovelace :: Prices -> ExecutionUnits -> Maybe Coin
calculateExecutionUnitsLovelace Prices
prices ExecutionUnits
eUnits =
Coin -> Maybe Coin
forall a. a -> Maybe a
forall (m :: * -> *) a. Monad m => a -> m a
return (Coin -> Maybe Coin) -> Coin -> Maybe Coin
forall a b. (a -> b) -> a -> b
$ Prices -> ExUnits -> Coin
Alonzo.txscriptfee Prices
prices (ExecutionUnits -> ExUnits
toAlonzoExUnits ExecutionUnits
eUnits)
scriptDataToInlineDatum :: L.Era ledgerera => HashableScriptData -> L.Datum ledgerera
scriptDataToInlineDatum :: forall ledgerera.
Era ledgerera =>
HashableScriptData -> Datum ledgerera
scriptDataToInlineDatum HashableScriptData
d =
BinaryData ledgerera -> Datum ledgerera
forall era. BinaryData era -> Datum era
L.Datum (BinaryData ledgerera -> Datum ledgerera)
-> (Data ledgerera -> BinaryData ledgerera)
-> Data ledgerera
-> Datum ledgerera
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Data ledgerera -> BinaryData ledgerera
forall era. Era era => Data era -> BinaryData era
L.dataToBinaryData (Data ledgerera -> Datum ledgerera)
-> Data ledgerera -> Datum ledgerera
forall a b. (a -> b) -> a -> b
$ HashableScriptData -> Data ledgerera
forall ledgerera.
Era ledgerera =>
HashableScriptData -> Data ledgerera
toAlonzoData HashableScriptData
d
binaryDataToScriptData
:: L.Era ledgerera
=> BabbageEraOnwards era
-> L.BinaryData ledgerera
-> HashableScriptData
binaryDataToScriptData :: forall ledgerera era.
Era ledgerera =>
BabbageEraOnwards era -> BinaryData ledgerera -> HashableScriptData
binaryDataToScriptData BabbageEraOnwards era
BabbageEraOnwardsBabbage BinaryData ledgerera
d =
Data ledgerera -> HashableScriptData
forall ledgerera. Data ledgerera -> HashableScriptData
fromAlonzoData (Data ledgerera -> HashableScriptData)
-> Data ledgerera -> HashableScriptData
forall a b. (a -> b) -> a -> b
$ BinaryData ledgerera -> Data ledgerera
forall era. Era era => BinaryData era -> Data era
L.binaryDataToData BinaryData ledgerera
d
binaryDataToScriptData BabbageEraOnwards era
BabbageEraOnwardsConway BinaryData ledgerera
d =
Data ledgerera -> HashableScriptData
forall ledgerera. Data ledgerera -> HashableScriptData
fromAlonzoData (Data ledgerera -> HashableScriptData)
-> Data ledgerera -> HashableScriptData
forall a b. (a -> b) -> a -> b
$ BinaryData ledgerera -> Data ledgerera
forall era. Era era => BinaryData era -> Data era
L.binaryDataToData BinaryData ledgerera
d