-- | A Haskell API for Cardano, tailored to the Hydra project.
--
-- This package provides a wrapper around the @cardano-ledger@, @cardano-api@ and
-- @plutus@ libraries with extra utilities and function commonly used across the
-- Hydra project.
--
-- NOTE: We always use the **latest era** available in our codebase, so to ease
-- type signatures and notations, we specialize any type of the @cardano-api@
-- normally parameterized by an era to the latest era 'Era'. As a consequence,
-- we've defined pattern synonyms for most constructors in the @cardano-api@ to
-- also get rid of era witnesses.
--
-- NOTE: This module also uses the **latest plutus version** available
-- (currently 'PlutusScriptV2'). So make sure that you give it a plutus script
-- of the right version (e.g. when compiling and serializing plutus-tx).
module Hydra.Cardano.Api (
  -- * Common type-alias
  StandardCrypto,
  Era,
  LedgerEra,
  ledgerEraVersion,
  LedgerProtocolParameters (..),

  -- * Wrapped Types
  module Hydra.Cardano.Api,

  -- ** UTxO
  UTxO,
  UTxO' (UTxO),

  -- * Extras
  module Extras,

  -- * Re-exports from @cardano-api@
  module X,
) where

import Cardano.Api as X hiding (
  AddressInEra (..),
  AddressTypeInEra (..),
  BalancedTxBody (..),
  Key (..),
  KeyWitness,
  PlutusScript,
  Script (..),
  ScriptInEra (..),
  ScriptLanguage (..),
  ScriptWitness (..),
  Tx (..),
  TxAuxScripts (..),
  TxBody (..),
  TxBodyContent (..),
  TxBodyScriptData (..),
  TxExtraKeyWitnesses (..),
  TxFee (..),
  TxIns,
  TxInsCollateral (..),
  TxInsReference (..),
  TxMetadataInEra (..),
  TxMintValue (..),
  TxOut (..),
  TxOutDatum (..),
  TxScriptValidity (..),
  TxValidityLowerBound (..),
  TxValidityUpperBound (..),
  UTxO (..),
  Witness (..),
  blue,
  createAndValidateTransactionBody,
  defaultTxBodyContent,
  fromLedgerValue,
  green,
  makeShelleyKeyWitness,
  policyId,
  queryEraHistory,
  queryProtocolParameters,
  queryStakePools,
  querySystemStart,
  red,
  scriptLanguageSupportedInEra,
  signShelleyTransaction,
  toLedgerUTxO,
  toLedgerValue,
  (<+>),
 )
import Cardano.Api.Byron as X (
  Address (..),
 )
import Cardano.Api.Ledger as X (
  PParams,
 )
import Cardano.Api.Shelley as X (
  AcquiringFailure (..),
  Address (..),
  Hash (HeaderHash),
  Key (..),
  PlutusScriptOrReferenceInput (PScript),
  PoolId,
  ShelleyGenesis (..),
  ShelleyLedgerEra,
  SigningKey (..),
  VerificationKey (..),
  fromAlonzoCostModels,
  fromAlonzoPrices,
  fromPlutusData,
  fromShelleyMetadata,
  toAlonzoPrices,
  toPlutusData,
  toShelleyMetadata,
  toShelleyNetwork,
 )
import Cardano.Api.UTxO (
  UTxO,
  UTxO' (..),
 )
import Cardano.Ledger.Coin as X (Coin (..))
import Hydra.Cardano.Api.Prelude (
  Era,
  LedgerEra,
  LedgerProtocolParameters,
  Map,
  StandardCrypto,
  ledgerEraVersion,
 )

import Hydra.Cardano.Api.Address ()
import Hydra.Cardano.Api.AddressInEra as Extras
import Hydra.Cardano.Api.BlockHeader as Extras
import Hydra.Cardano.Api.ChainPoint as Extras
import Hydra.Cardano.Api.CtxTx as Extras
import Hydra.Cardano.Api.CtxUTxO as Extras
import Hydra.Cardano.Api.ExecutionUnits as Extras
import Hydra.Cardano.Api.Hash as Extras
import Hydra.Cardano.Api.KeyWitness as Extras
import Hydra.Cardano.Api.NetworkId ()
import Hydra.Cardano.Api.PlutusScript as Extras
import Hydra.Cardano.Api.PolicyId as Extras
import Hydra.Cardano.Api.ReferenceScript as Extras
import Hydra.Cardano.Api.ScriptData as Extras
import Hydra.Cardano.Api.ScriptDatum as Extras
import Hydra.Cardano.Api.ScriptHash as Extras
import Hydra.Cardano.Api.Tx as Extras hiding (Tx)
import Hydra.Cardano.Api.TxBody as Extras
import Hydra.Cardano.Api.TxId as Extras
import Hydra.Cardano.Api.TxIn as Extras
import Hydra.Cardano.Api.TxOut as Extras
import Hydra.Cardano.Api.TxOutDatum as Extras
import Hydra.Cardano.Api.TxOutValue as Extras
import Hydra.Cardano.Api.TxScriptValidity as Extras
import Hydra.Cardano.Api.UTxO as Extras
import Hydra.Cardano.Api.ValidityInterval as Extras
import Hydra.Cardano.Api.Value as Extras
import Hydra.Cardano.Api.VerificationKey ()
import Hydra.Cardano.Api.Witness as Extras

import Cardano.Api qualified
import Cardano.Api.Shelley qualified
import Cardano.Ledger.Alonzo.TxAuxData qualified as Ledger
import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
import Cardano.Ledger.Core qualified as Ledger
import Cardano.Ledger.Keys qualified as Ledger
import Data.ByteString.Short (ShortByteString)
import Prelude

-- ** AddressInEra

type AddressInEra = Cardano.Api.AddressInEra Era
{-# COMPLETE ShelleyAddressInEra, ByronAddressInEra #-}

pattern ShelleyAddressInEra :: Address ShelleyAddr -> AddressInEra
pattern $mShelleyAddressInEra :: forall {r}.
AddressInEra -> (Address ShelleyAddr -> r) -> ((# #) -> r) -> r
$bShelleyAddressInEra :: Address ShelleyAddr -> AddressInEra
ShelleyAddressInEra{AddressInEra -> Address ShelleyAddr
address} <-
  Cardano.Api.AddressInEra Cardano.Api.ShelleyAddressInEra{} address
  where
    ShelleyAddressInEra =
      AddressTypeInEra ShelleyAddr Era
-> Address ShelleyAddr -> AddressInEra
forall addrtype era.
AddressTypeInEra addrtype era
-> Address addrtype -> AddressInEra era
Cardano.Api.AddressInEra AddressTypeInEra ShelleyAddr Era
ShelleyAddressInAnyEra

pattern ByronAddressInEra :: Address ByronAddr -> AddressInEra
pattern $mByronAddressInEra :: forall {r}.
AddressInEra -> (Address ByronAddr -> r) -> ((# #) -> r) -> r
$bByronAddressInEra :: Address ByronAddr -> AddressInEra
ByronAddressInEra{AddressInEra -> Address ByronAddr
byronAddress} <-
  Cardano.Api.AddressInEra Cardano.Api.ByronAddressInAnyEra byronAddress
  where
    ByronAddressInEra =
      AddressTypeInEra ByronAddr Era -> Address ByronAddr -> AddressInEra
forall addrtype era.
AddressTypeInEra addrtype era
-> Address addrtype -> AddressInEra era
Cardano.Api.AddressInEra AddressTypeInEra ByronAddr Era
ByronAddressInAnyEra

-- ** AddressTypeInEra

type AddressTypeInEra addrType = Cardano.Api.AddressTypeInEra addrType Era
{-# COMPLETE ByronAddressInAnyEra, ShelleyAddressInAnyEra #-}

pattern ByronAddressInAnyEra :: AddressTypeInEra ByronAddr
pattern $mByronAddressInAnyEra :: forall {r}.
AddressTypeInEra ByronAddr Era -> ((# #) -> r) -> ((# #) -> r) -> r
$bByronAddressInAnyEra :: AddressTypeInEra ByronAddr Era
ByronAddressInAnyEra <-
  Cardano.Api.ByronAddressInAnyEra
  where
    ByronAddressInAnyEra =
      AddressTypeInEra ByronAddr Era
forall era. AddressTypeInEra ByronAddr era
Cardano.Api.ByronAddressInAnyEra

pattern ShelleyAddressInAnyEra :: AddressTypeInEra ShelleyAddr
pattern $mShelleyAddressInAnyEra :: forall {r}.
AddressTypeInEra ShelleyAddr Era
-> ((# #) -> r) -> ((# #) -> r) -> r
$bShelleyAddressInAnyEra :: AddressTypeInEra ShelleyAddr Era
ShelleyAddressInAnyEra <-
  Cardano.Api.ShelleyAddressInEra _
  where
    ShelleyAddressInAnyEra =
      ShelleyBasedEra Era -> AddressTypeInEra ShelleyAddr Era
forall era. ShelleyBasedEra era -> AddressTypeInEra ShelleyAddr era
Cardano.Api.ShelleyAddressInEra ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

-- ** BalancedTxBody

type BalancedTxBody = Cardano.Api.BalancedTxBody Era
{-# COMPLETE BalancedTxBody #-}

pattern BalancedTxBody :: TxBodyContent BuildTx -> TxBody -> TxOut CtxTx -> Coin -> BalancedTxBody
pattern $mBalancedTxBody :: forall {r}.
BalancedTxBody
-> (TxBodyContent BuildTx -> TxBody -> TxOut CtxTx -> Coin -> r)
-> ((# #) -> r)
-> r
$bBalancedTxBody :: TxBodyContent BuildTx
-> TxBody -> TxOut CtxTx -> Coin -> BalancedTxBody
BalancedTxBody{BalancedTxBody -> TxBodyContent BuildTx
balancedTxBodyContent, BalancedTxBody -> TxBody
balancedTxBody, BalancedTxBody -> TxOut CtxTx
balancedTxChangeOutput, BalancedTxBody -> Coin
balancedTxFee} <-
  Cardano.Api.BalancedTxBody balancedTxBodyContent balancedTxBody balancedTxChangeOutput balancedTxFee
  where
    BalancedTxBody =
      TxBodyContent BuildTx
-> TxBody -> TxOut CtxTx -> Coin -> BalancedTxBody
forall era.
TxBodyContent BuildTx era
-> TxBody era -> TxOut CtxTx era -> Coin -> BalancedTxBody era
Cardano.Api.BalancedTxBody

-- ** KeyWitness

type KeyWitness = Cardano.Api.KeyWitness Era
{-# COMPLETE ShelleyBootstrapWitness, ShelleyKeyWitness #-}

pattern ShelleyBootstrapWitness :: Ledger.BootstrapWitness StandardCrypto -> KeyWitness
pattern $mShelleyBootstrapWitness :: forall {r}.
KeyWitness
-> (BootstrapWitness StandardCrypto -> r) -> ((# #) -> r) -> r
$bShelleyBootstrapWitness :: BootstrapWitness StandardCrypto -> KeyWitness
ShelleyBootstrapWitness{KeyWitness -> BootstrapWitness StandardCrypto
shelleyBootstrapWitness} <-
  Cardano.Api.Shelley.ShelleyBootstrapWitness _ shelleyBootstrapWitness
  where
    ShelleyBootstrapWitness =
      ShelleyBasedEra Era
-> BootstrapWitness StandardCrypto -> KeyWitness
forall era.
ShelleyBasedEra era
-> BootstrapWitness StandardCrypto -> KeyWitness era
Cardano.Api.Shelley.ShelleyBootstrapWitness ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

pattern ShelleyKeyWitness :: Ledger.WitVKey 'Ledger.Witness StandardCrypto -> KeyWitness
pattern $mShelleyKeyWitness :: forall {r}.
KeyWitness
-> (WitVKey 'Witness StandardCrypto -> r) -> ((# #) -> r) -> r
$bShelleyKeyWitness :: WitVKey 'Witness StandardCrypto -> KeyWitness
ShelleyKeyWitness{KeyWitness -> WitVKey 'Witness StandardCrypto
shelleyKeyWitness} <-
  Cardano.Api.Shelley.ShelleyKeyWitness _ shelleyKeyWitness
  where
    ShelleyKeyWitness =
      ShelleyBasedEra Era
-> WitVKey 'Witness StandardCrypto -> KeyWitness
forall era.
ShelleyBasedEra era
-> WitVKey 'Witness StandardCrypto -> KeyWitness era
Cardano.Api.Shelley.ShelleyKeyWitness ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

-- ** PlutusScript

type PlutusScript = Cardano.Api.PlutusScript PlutusScriptV2
{-# COMPLETE PlutusScriptSerialised #-}

pattern PlutusScriptSerialised :: ShortByteString -> PlutusScript
pattern $mPlutusScriptSerialised :: forall {r}.
PlutusScript -> (ShortByteString -> r) -> ((# #) -> r) -> r
$bPlutusScriptSerialised :: ShortByteString -> PlutusScript
PlutusScriptSerialised{PlutusScript -> ShortByteString
plutusScriptSerialised} <-
  Cardano.Api.Shelley.PlutusScriptSerialised plutusScriptSerialised
  where
    PlutusScriptSerialised =
      ShortByteString -> PlutusScript
forall lang. ShortByteString -> PlutusScript lang
Cardano.Api.Shelley.PlutusScriptSerialised

-- ** Script

type Script = Cardano.Api.Script PlutusScriptV2
{-# COMPLETE PlutusScript #-}

pattern PlutusScript :: PlutusScript -> Script
pattern $mPlutusScript :: forall {r}. Script -> (PlutusScript -> r) -> ((# #) -> r) -> r
$bPlutusScript :: PlutusScript -> Script
PlutusScript{Script -> PlutusScript
plutusScript} <-
  Cardano.Api.Shelley.PlutusScript _ plutusScript
  where
    PlutusScript =
      PlutusScriptVersion PlutusScriptV2 -> PlutusScript -> Script
forall lang.
PlutusScriptVersion lang -> PlutusScript lang -> Script lang
Cardano.Api.Shelley.PlutusScript PlutusScriptVersion PlutusScriptV2
PlutusScriptV2

-- ** ScriptInEra

type ScriptInEra = Cardano.Api.ScriptInEra Era

-- ** ScriptLanguage

type ScriptLanguage = Cardano.Api.ScriptLanguage PlutusScriptV2
{-# COMPLETE PlutusScriptLanguage #-}

pattern PlutusScriptLanguage :: ScriptLanguage
pattern $mPlutusScriptLanguage :: forall {r}. ScriptLanguage -> ((# #) -> r) -> ((# #) -> r) -> r
$bPlutusScriptLanguage :: ScriptLanguage
PlutusScriptLanguage <-
  Cardano.Api.Shelley.PlutusScriptLanguage _
  where
    PlutusScriptLanguage =
      PlutusScriptVersion PlutusScriptV2 -> ScriptLanguage
forall lang. PlutusScriptVersion lang -> ScriptLanguage lang
Cardano.Api.Shelley.PlutusScriptLanguage PlutusScriptVersion PlutusScriptV2
PlutusScriptV2

-- ** ScriptWitness

type ScriptWitness witCtx = Cardano.Api.ScriptWitness witCtx Era
{-# COMPLETE PlutusScriptWitness #-}

pattern PlutusScriptWitness ::
  PlutusScript ->
  ScriptDatum witctx ->
  ScriptRedeemer ->
  ExecutionUnits ->
  ScriptWitness witctx
pattern $mPlutusScriptWitness :: forall {r} {witctx}.
ScriptWitness witctx
-> (PlutusScript
    -> ScriptDatum witctx -> ScriptRedeemer -> ExecutionUnits -> r)
-> ((# #) -> r)
-> r
$bPlutusScriptWitness :: forall witctx.
PlutusScript
-> ScriptDatum witctx
-> ScriptRedeemer
-> ExecutionUnits
-> ScriptWitness witctx
PlutusScriptWitness
  { forall witctx. ScriptWitness witctx -> PlutusScript
plutusScriptWitnessScript
  , forall witctx. ScriptWitness witctx -> ScriptDatum witctx
plutusScriptWitnessDatum
  , forall witctx. ScriptWitness witctx -> ScriptRedeemer
plutusScriptWitnessRedeemer
  , forall witctx. ScriptWitness witctx -> ExecutionUnits
plutusScriptWitnessExecutionUnits
  } <-
  Cardano.Api.PlutusScriptWitness
    _
    PlutusScriptV2
    (PScript plutusScriptWitnessScript)
    plutusScriptWitnessDatum
    plutusScriptWitnessRedeemer
    plutusScriptWitnessExecutionUnits
  where
    PlutusScriptWitness =
      ScriptLanguageInEra PlutusScriptV2 Era
-> PlutusScriptVersion PlutusScriptV2
-> PlutusScriptOrReferenceInput PlutusScriptV2
-> ScriptDatum witctx
-> ScriptRedeemer
-> ExecutionUnits
-> ScriptWitness witctx Era
forall lang era witctx.
ScriptLanguageInEra lang era
-> PlutusScriptVersion lang
-> PlutusScriptOrReferenceInput lang
-> ScriptDatum witctx
-> ScriptRedeemer
-> ExecutionUnits
-> ScriptWitness witctx era
Cardano.Api.PlutusScriptWitness
        ScriptLanguageInEra PlutusScriptV2 Era
forall lang era.
HasScriptLanguageInEra lang era =>
ScriptLanguageInEra lang era
scriptLanguageInEra
        PlutusScriptVersion PlutusScriptV2
PlutusScriptV2
        (PlutusScriptOrReferenceInput PlutusScriptV2
 -> ScriptDatum witctx
 -> ScriptRedeemer
 -> ExecutionUnits
 -> ScriptWitness witctx Era)
-> (PlutusScript -> PlutusScriptOrReferenceInput PlutusScriptV2)
-> PlutusScript
-> ScriptDatum witctx
-> ScriptRedeemer
-> ExecutionUnits
-> ScriptWitness witctx Era
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PlutusScript -> PlutusScriptOrReferenceInput PlutusScriptV2
forall lang. PlutusScript lang -> PlutusScriptOrReferenceInput lang
PScript

-- ** Tx

type Tx = Cardano.Api.Tx Era
{-# COMPLETE Tx #-}
{-# COMPLETE ShelleyTxBody #-}

pattern Tx :: TxBody -> [KeyWitness] -> Tx
pattern $mTx :: forall {r}.
Tx -> (TxBody -> [KeyWitness] -> r) -> ((# #) -> r) -> r
$bTx :: TxBody -> [KeyWitness] -> Tx
Tx{Tx -> TxBody
txBody, Tx -> [KeyWitness]
txKeyWitnesses} <-
  Cardano.Api.Tx txBody txKeyWitnesses
  where
    Tx =
      TxBody -> [KeyWitness] -> Tx
forall era. TxBody era -> [KeyWitness era] -> Tx era
Cardano.Api.Tx

pattern ShelleyTxBody ::
  Ledger.TxBody LedgerEra ->
  [Ledger.Script LedgerEra] ->
  TxBodyScriptData ->
  Maybe (Ledger.AlonzoTxAuxData LedgerEra) ->
  TxScriptValidity ->
  TxBody
pattern $mShelleyTxBody :: forall {r}.
TxBody
-> (TxBody (ShelleyLedgerEra Era)
    -> [Script (ShelleyLedgerEra Era)]
    -> TxBodyScriptData
    -> Maybe (AlonzoTxAuxData (ShelleyLedgerEra Era))
    -> TxScriptValidity
    -> r)
-> ((# #) -> r)
-> r
$bShelleyTxBody :: TxBody (ShelleyLedgerEra Era)
-> [Script (ShelleyLedgerEra Era)]
-> TxBodyScriptData
-> Maybe (AlonzoTxAuxData (ShelleyLedgerEra Era))
-> TxScriptValidity
-> TxBody
ShelleyTxBody
  { TxBody -> TxBody (ShelleyLedgerEra Era)
txBodyLedgerTxBody
  , TxBody -> [Script (ShelleyLedgerEra Era)]
txBodyScripts
  , TxBody -> TxBodyScriptData
txBodyScriptData
  , TxBody -> Maybe (AlonzoTxAuxData (ShelleyLedgerEra Era))
txBodyAuxiliaryData
  , TxBody -> TxScriptValidity
txBodyScriptValidity
  } <-
  Cardano.Api.Shelley.ShelleyTxBody
    _
    txBodyLedgerTxBody
    txBodyScripts
    txBodyScriptData
    txBodyAuxiliaryData
    txBodyScriptValidity
  where
    ShelleyTxBody =
      ShelleyBasedEra Era
-> TxBody (ShelleyLedgerEra Era)
-> [Script (ShelleyLedgerEra Era)]
-> TxBodyScriptData
-> Maybe (TxAuxData (ShelleyLedgerEra Era))
-> TxScriptValidity
-> TxBody
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (TxAuxData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
Cardano.Api.Shelley.ShelleyTxBody ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

signShelleyTransaction :: TxBody -> [ShelleyWitnessSigningKey] -> Tx
signShelleyTransaction :: TxBody -> [ShelleyWitnessSigningKey] -> Tx
signShelleyTransaction = ShelleyBasedEra Era -> TxBody -> [ShelleyWitnessSigningKey] -> Tx
forall era.
ShelleyBasedEra era
-> TxBody era -> [ShelleyWitnessSigningKey] -> Tx era
Cardano.Api.signShelleyTransaction ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

-- ** TxAuxScripts

type TxAuxScripts = Cardano.Api.TxAuxScripts Era
{-# COMPLETE TxAuxScriptsNone, TxAuxScripts #-}

pattern TxAuxScriptsNone :: TxAuxScripts
pattern $mTxAuxScriptsNone :: forall {r}. TxAuxScripts -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxAuxScriptsNone :: TxAuxScripts
TxAuxScriptsNone <-
  Cardano.Api.TxAuxScriptsNone
  where
    TxAuxScriptsNone =
      TxAuxScripts
forall era. TxAuxScripts era
Cardano.Api.TxAuxScriptsNone

pattern TxAuxScripts :: [ScriptInEra] -> TxAuxScripts
pattern $mTxAuxScripts :: forall {r}.
TxAuxScripts -> ([ScriptInEra] -> r) -> ((# #) -> r) -> r
$bTxAuxScripts :: [ScriptInEra] -> TxAuxScripts
TxAuxScripts{TxAuxScripts -> [ScriptInEra]
txAuxScripts'} <-
  Cardano.Api.TxAuxScripts _ txAuxScripts'
  where
    TxAuxScripts =
      AllegraEraOnwards Era -> [ScriptInEra] -> TxAuxScripts
forall era.
AllegraEraOnwards era -> [ScriptInEra era] -> TxAuxScripts era
Cardano.Api.TxAuxScripts AllegraEraOnwards Era
forall era. IsAllegraBasedEra era => AllegraEraOnwards era
allegraBasedEra

-- ** TxBody

type TxBody = Cardano.Api.TxBody Era
{-# COMPLETE TxBody #-}

pattern TxBody :: TxBodyContent ViewTx -> TxBody
pattern $mTxBody :: forall {r}.
TxBody -> (TxBodyContent ViewTx -> r) -> ((# #) -> r) -> r
TxBody{TxBody -> TxBodyContent ViewTx
txBodyContent} <-
  Cardano.Api.TxBody txBodyContent
{-# COMPLETE TxBody #-}

createAndValidateTransactionBody :: TxBodyContent BuildTx -> Either TxBodyError TxBody
createAndValidateTransactionBody :: TxBodyContent BuildTx -> Either TxBodyError TxBody
createAndValidateTransactionBody = ShelleyBasedEra Era
-> TxBodyContent BuildTx -> Either TxBodyError TxBody
forall era.
ShelleyBasedEra era
-> TxBodyContent BuildTx era -> Either TxBodyError (TxBody era)
Cardano.Api.createAndValidateTransactionBody ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

defaultTxBodyContent :: TxBodyContent BuildTx
defaultTxBodyContent :: TxBodyContent BuildTx
defaultTxBodyContent = ShelleyBasedEra Era -> TxBodyContent BuildTx
forall era. ShelleyBasedEra era -> TxBodyContent BuildTx era
Cardano.Api.defaultTxBodyContent ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

-- ** TxBodyContent

type TxBodyContent buidl = Cardano.Api.TxBodyContent buidl Era
{-# COMPLETE TxBodyContent #-}

pattern TxBodyContent ::
  TxIns buidl ->
  TxInsCollateral ->
  TxInsReference buidl ->
  [TxOut CtxTx] ->
  TxTotalCollateral Era ->
  TxReturnCollateral CtxTx Era ->
  TxFee ->
  TxValidityLowerBound ->
  TxValidityUpperBound ->
  TxMetadataInEra ->
  TxAuxScripts ->
  TxExtraKeyWitnesses ->
  BuildTxWith buidl (Maybe (LedgerProtocolParameters Era)) ->
  TxWithdrawals buidl Era ->
  TxCertificates buidl Era ->
  TxUpdateProposal Era ->
  TxMintValue buidl ->
  TxScriptValidity ->
  Maybe (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era)) ->
  Maybe (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era)) ->
  Maybe (Featured ConwayEraOnwards Era Coin) ->
  Maybe (Featured ConwayEraOnwards Era Coin) ->
  TxBodyContent buidl
pattern $mTxBodyContent :: forall {r} {buidl}.
TxBodyContent buidl
-> (TxIns buidl
    -> TxInsCollateral
    -> TxInsReference buidl
    -> [TxOut CtxTx]
    -> TxTotalCollateral Era
    -> TxReturnCollateral CtxTx Era
    -> TxFee
    -> TxValidityLowerBound
    -> TxValidityUpperBound
    -> TxMetadataInEra
    -> TxAuxScripts
    -> TxExtraKeyWitnesses
    -> BuildTxWith buidl (Maybe (LedgerProtocolParameters Era))
    -> TxWithdrawals buidl Era
    -> TxCertificates buidl Era
    -> TxUpdateProposal Era
    -> TxMintValue buidl
    -> TxScriptValidity
    -> Maybe
         (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era))
    -> Maybe
         (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era))
    -> Maybe (Featured ConwayEraOnwards Era Coin)
    -> Maybe (Featured ConwayEraOnwards Era Coin)
    -> r)
-> ((# #) -> r)
-> r
$bTxBodyContent :: forall buidl.
TxIns buidl
-> TxInsCollateral
-> TxInsReference buidl
-> [TxOut CtxTx]
-> TxTotalCollateral Era
-> TxReturnCollateral CtxTx Era
-> TxFee
-> TxValidityLowerBound
-> TxValidityUpperBound
-> TxMetadataInEra
-> TxAuxScripts
-> TxExtraKeyWitnesses
-> BuildTxWith buidl (Maybe (LedgerProtocolParameters Era))
-> TxWithdrawals buidl Era
-> TxCertificates buidl Era
-> TxUpdateProposal Era
-> TxMintValue buidl
-> TxScriptValidity
-> Maybe
     (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era))
-> Maybe
     (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era))
-> Maybe (Featured ConwayEraOnwards Era Coin)
-> Maybe (Featured ConwayEraOnwards Era Coin)
-> TxBodyContent buidl
TxBodyContent
  { forall buidl. TxBodyContent buidl -> TxIns buidl
txIns
  , forall buidl. TxBodyContent buidl -> TxInsCollateral
txInsCollateral
  , forall buidl. TxBodyContent buidl -> TxInsReference buidl
txInsReference
  , forall buidl. TxBodyContent buidl -> [TxOut CtxTx]
txOuts
  , forall buidl. TxBodyContent buidl -> TxTotalCollateral Era
txTotalCollateral
  , forall buidl. TxBodyContent buidl -> TxReturnCollateral CtxTx Era
txReturnCollateral
  , forall buidl. TxBodyContent buidl -> TxFee
txFee
  , forall buidl. TxBodyContent buidl -> TxValidityLowerBound
txValidityLowerBound
  , forall buidl. TxBodyContent buidl -> TxValidityUpperBound
txValidityUpperBound
  , forall buidl. TxBodyContent buidl -> TxMetadataInEra
txMetadata
  , forall buidl. TxBodyContent buidl -> TxAuxScripts
txAuxScripts
  , forall buidl. TxBodyContent buidl -> TxExtraKeyWitnesses
txExtraKeyWits
  , forall buidl.
TxBodyContent buidl
-> BuildTxWith buidl (Maybe (LedgerProtocolParameters Era))
txProtocolParams
  , forall buidl. TxBodyContent buidl -> TxWithdrawals buidl Era
txWithdrawals
  , forall buidl. TxBodyContent buidl -> TxCertificates buidl Era
txCertificates
  , forall buidl. TxBodyContent buidl -> TxUpdateProposal Era
txUpdateProposal
  , forall buidl. TxBodyContent buidl -> TxMintValue buidl
txMintValue
  , forall buidl. TxBodyContent buidl -> TxScriptValidity
txScriptValidity
  , forall buidl.
TxBodyContent buidl
-> Maybe
     (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era))
txProposalProcedures
  , forall buidl.
TxBodyContent buidl
-> Maybe
     (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era))
txVotingProcedures
  , forall buidl.
TxBodyContent buidl -> Maybe (Featured ConwayEraOnwards Era Coin)
txCurrentTreasuryValue
  , forall buidl.
TxBodyContent buidl -> Maybe (Featured ConwayEraOnwards Era Coin)
txTreasuryDonation
  } <-
  Cardano.Api.TxBodyContent
    txIns
    txInsCollateral
    txInsReference
    txOuts
    txTotalCollateral
    txReturnCollateral
    txFee
    txValidityLowerBound
    txValidityUpperBound
    txMetadata
    txAuxScripts
    txExtraKeyWits
    txProtocolParams
    txWithdrawals
    txCertificates
    txUpdateProposal
    txMintValue
    txScriptValidity
    txProposalProcedures
    txVotingProcedures
    txCurrentTreasuryValue
    txTreasuryDonation
  where
    TxBodyContent = TxIns buidl Era
-> TxInsCollateral
-> TxInsReference buidl Era
-> [TxOut CtxTx]
-> TxTotalCollateral Era
-> TxReturnCollateral CtxTx Era
-> TxFee
-> TxValidityLowerBound
-> TxValidityUpperBound
-> TxMetadataInEra
-> TxAuxScripts
-> TxExtraKeyWitnesses
-> BuildTxWith buidl (Maybe (LedgerProtocolParameters Era))
-> TxWithdrawals buidl Era
-> TxCertificates buidl Era
-> TxUpdateProposal Era
-> TxMintValue buidl Era
-> TxScriptValidity
-> Maybe
     (Featured ConwayEraOnwards Era (TxProposalProcedures buidl Era))
-> Maybe
     (Featured ConwayEraOnwards Era (TxVotingProcedures buidl Era))
-> Maybe (Featured ConwayEraOnwards Era Coin)
-> Maybe (Featured ConwayEraOnwards Era Coin)
-> TxBodyContent buidl Era
forall build era.
TxIns build era
-> TxInsCollateral era
-> TxInsReference build era
-> [TxOut CtxTx era]
-> TxTotalCollateral era
-> TxReturnCollateral CtxTx era
-> TxFee era
-> TxValidityLowerBound era
-> TxValidityUpperBound era
-> TxMetadataInEra era
-> TxAuxScripts era
-> TxExtraKeyWitnesses era
-> BuildTxWith build (Maybe (LedgerProtocolParameters era))
-> TxWithdrawals build era
-> TxCertificates build era
-> TxUpdateProposal era
-> TxMintValue build era
-> TxScriptValidity era
-> Maybe
     (Featured ConwayEraOnwards era (TxProposalProcedures build era))
-> Maybe
     (Featured ConwayEraOnwards era (TxVotingProcedures build era))
-> Maybe (Featured ConwayEraOnwards era Coin)
-> Maybe (Featured ConwayEraOnwards era Coin)
-> TxBodyContent build era
Cardano.Api.TxBodyContent

-- ** TxBodyScriptData

type TxBodyScriptData = Cardano.Api.TxBodyScriptData Era
{-# COMPLETE TxBodyNoScriptData, TxBodyScriptData #-}

pattern TxBodyNoScriptData :: TxBodyScriptData
pattern $mTxBodyNoScriptData :: forall {r}. TxBodyScriptData -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxBodyNoScriptData :: TxBodyScriptData
TxBodyNoScriptData <-
  Cardano.Api.TxBodyNoScriptData
  where
    TxBodyNoScriptData =
      TxBodyScriptData
forall era. TxBodyScriptData era
Cardano.Api.TxBodyNoScriptData

pattern TxBodyScriptData ::
  Ledger.TxDats (ShelleyLedgerEra Era) ->
  Ledger.Redeemers (ShelleyLedgerEra Era) ->
  TxBodyScriptData
pattern $mTxBodyScriptData :: forall {r}.
TxBodyScriptData
-> (TxDats (ShelleyLedgerEra Era)
    -> Redeemers (ShelleyLedgerEra Era) -> r)
-> ((# #) -> r)
-> r
$bTxBodyScriptData :: TxDats (ShelleyLedgerEra Era)
-> Redeemers (ShelleyLedgerEra Era) -> TxBodyScriptData
TxBodyScriptData{TxBodyScriptData -> TxDats (ShelleyLedgerEra Era)
txBodyScriptDatums, TxBodyScriptData -> Redeemers (ShelleyLedgerEra Era)
txBodyScriptRedeemers} <-
  Cardano.Api.TxBodyScriptData _ txBodyScriptDatums txBodyScriptRedeemers
  where
    TxBodyScriptData =
      AlonzoEraOnwards Era
-> TxDats (ShelleyLedgerEra Era)
-> Redeemers (ShelleyLedgerEra Era)
-> TxBodyScriptData
forall era.
AlonzoEraOnwardsConstraints era =>
AlonzoEraOnwards era
-> TxDats (ShelleyLedgerEra era)
-> Redeemers (ShelleyLedgerEra era)
-> TxBodyScriptData era
Cardano.Api.TxBodyScriptData AlonzoEraOnwards Era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra

-- ** TxExtraKeyWitnesses

type TxExtraKeyWitnesses = Cardano.Api.TxExtraKeyWitnesses Era
{-# COMPLETE TxExtraKeyWitnessesNone, TxExtraKeyWitnesses #-}

pattern TxExtraKeyWitnessesNone :: TxExtraKeyWitnesses
pattern $mTxExtraKeyWitnessesNone :: forall {r}.
TxExtraKeyWitnesses -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxExtraKeyWitnessesNone :: TxExtraKeyWitnesses
TxExtraKeyWitnessesNone <-
  Cardano.Api.TxExtraKeyWitnessesNone
  where
    TxExtraKeyWitnessesNone = TxExtraKeyWitnesses
forall era. TxExtraKeyWitnesses era
Cardano.Api.TxExtraKeyWitnessesNone

pattern TxExtraKeyWitnesses :: [Hash PaymentKey] -> TxExtraKeyWitnesses
pattern $mTxExtraKeyWitnesses :: forall {r}.
TxExtraKeyWitnesses
-> ([Hash PaymentKey] -> r) -> ((# #) -> r) -> r
$bTxExtraKeyWitnesses :: [Hash PaymentKey] -> TxExtraKeyWitnesses
TxExtraKeyWitnesses{TxExtraKeyWitnesses -> [Hash PaymentKey]
txExtraKeyWitnesses} <-
  Cardano.Api.TxExtraKeyWitnesses _ txExtraKeyWitnesses
  where
    TxExtraKeyWitnesses =
      AlonzoEraOnwards Era -> [Hash PaymentKey] -> TxExtraKeyWitnesses
forall era.
AlonzoEraOnwards era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
Cardano.Api.TxExtraKeyWitnesses AlonzoEraOnwards Era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra

-- ** TxFee

type TxFee = Cardano.Api.TxFee Era
{-# COMPLETE TxFeeExplicit #-}

pattern TxFeeExplicit :: Coin -> TxFee
pattern $mTxFeeExplicit :: forall {r}. TxFee -> (Coin -> r) -> ((# #) -> r) -> r
$bTxFeeExplicit :: Coin -> TxFee
TxFeeExplicit{TxFee -> Coin
txFeeExplicit} <-
  Cardano.Api.TxFeeExplicit _ txFeeExplicit
  where
    TxFeeExplicit =
      ShelleyBasedEra Era -> Coin -> TxFee
forall era. ShelleyBasedEra era -> Coin -> TxFee era
Cardano.Api.TxFeeExplicit ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

-- ** TxIns

type TxIns buidl = [(TxIn, BuildTxWith buidl (Cardano.Api.Witness WitCtxTxIn Era))]

-- ** TxInsReference

type TxInsReference buidl = Cardano.Api.TxInsReference buidl Era
{-# COMPLETE TxInsReferenceNone, TxInsReference #-}

pattern TxInsReferenceNone :: TxInsReference buidl
pattern $mTxInsReferenceNone :: forall {r} {buidl}.
TxInsReference buidl -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxInsReferenceNone :: forall buidl. TxInsReference buidl
TxInsReferenceNone <-
  Cardano.Api.TxInsReferenceNone
  where
    TxInsReferenceNone =
      TxInsReference buidl Era
forall build era. TxInsReference build era
Cardano.Api.TxInsReferenceNone

pattern TxInsReference :: [TxIn] -> TxInsReference buidl
pattern $mTxInsReference :: forall {r} {buidl}.
TxInsReference buidl -> ([TxIn] -> r) -> ((# #) -> r) -> r
$bTxInsReference :: forall buidl. [TxIn] -> TxInsReference buidl
TxInsReference{forall buidl. TxInsReference buidl -> [TxIn]
txInsReference'} <-
  Cardano.Api.TxInsReference _ txInsReference'
  where
    TxInsReference =
      BabbageEraOnwards Era -> [TxIn] -> TxInsReference buidl Era
forall era build.
BabbageEraOnwards era -> [TxIn] -> TxInsReference build era
Cardano.Api.TxInsReference BabbageEraOnwards Era
forall era. IsBabbageBasedEra era => BabbageEraOnwards era
babbageBasedEra

-- ** TxInsCollateral

type TxInsCollateral = Cardano.Api.TxInsCollateral Era
{-# COMPLETE TxInsCollateralNone, TxInsCollateral #-}

pattern TxInsCollateralNone :: TxInsCollateral
pattern $mTxInsCollateralNone :: forall {r}. TxInsCollateral -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxInsCollateralNone :: TxInsCollateral
TxInsCollateralNone <-
  Cardano.Api.TxInsCollateralNone
  where
    TxInsCollateralNone =
      TxInsCollateral
forall era. TxInsCollateral era
Cardano.Api.TxInsCollateralNone

pattern TxInsCollateral :: [TxIn] -> TxInsCollateral
pattern $mTxInsCollateral :: forall {r}. TxInsCollateral -> ([TxIn] -> r) -> ((# #) -> r) -> r
$bTxInsCollateral :: [TxIn] -> TxInsCollateral
TxInsCollateral{TxInsCollateral -> [TxIn]
txInsCollateral'} <-
  Cardano.Api.TxInsCollateral _ txInsCollateral'
  where
    TxInsCollateral =
      AlonzoEraOnwards Era -> [TxIn] -> TxInsCollateral
forall era. AlonzoEraOnwards era -> [TxIn] -> TxInsCollateral era
Cardano.Api.TxInsCollateral AlonzoEraOnwards Era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra

-- ** TxMetadataInEra

type TxMetadataInEra = Cardano.Api.TxMetadataInEra Era
{-# COMPLETE TxMetadataNone, TxMetadataInEra #-}

pattern TxMetadataNone :: TxMetadataInEra
pattern $mTxMetadataNone :: forall {r}. TxMetadataInEra -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxMetadataNone :: TxMetadataInEra
TxMetadataNone <-
  Cardano.Api.TxMetadataNone
  where
    TxMetadataNone =
      TxMetadataInEra
forall era. TxMetadataInEra era
Cardano.Api.TxMetadataNone

pattern TxMetadataInEra :: TxMetadata -> TxMetadataInEra
pattern $mTxMetadataInEra :: forall {r}.
TxMetadataInEra -> (TxMetadata -> r) -> ((# #) -> r) -> r
$bTxMetadataInEra :: TxMetadata -> TxMetadataInEra
TxMetadataInEra{TxMetadataInEra -> TxMetadata
txMetadataInEra} <-
  Cardano.Api.TxMetadataInEra _ txMetadataInEra
  where
    TxMetadataInEra =
      ShelleyBasedEra Era -> TxMetadata -> TxMetadataInEra
forall era.
ShelleyBasedEra era -> TxMetadata -> TxMetadataInEra era
Cardano.Api.TxMetadataInEra ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra

-- ** TxMintValue

type TxMintValue buidl = Cardano.Api.TxMintValue buidl Era
{-# COMPLETE TxMintValueNone, TxMintValue #-}

pattern TxMintValueNone :: TxMintValue buidl
pattern $mTxMintValueNone :: forall {r} {buidl}.
TxMintValue buidl -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxMintValueNone :: forall buidl. TxMintValue buidl
TxMintValueNone <-
  Cardano.Api.TxMintNone
  where
    TxMintValueNone =
      TxMintValue buidl Era
forall build era. TxMintValue build era
Cardano.Api.TxMintNone

pattern TxMintValue ::
  Value ->
  BuildTxWith buidl (Map PolicyId (ScriptWitness WitCtxMint)) ->
  TxMintValue buidl
pattern $mTxMintValue :: forall {r} {buidl}.
TxMintValue buidl
-> (Value
    -> BuildTxWith buidl (Map PolicyId (ScriptWitness WitCtxMint))
    -> r)
-> ((# #) -> r)
-> r
$bTxMintValue :: forall buidl.
Value
-> BuildTxWith buidl (Map PolicyId (ScriptWitness WitCtxMint))
-> TxMintValue buidl
TxMintValue{forall buidl. TxMintValue buidl -> Value
txMintValueInEra, forall buidl.
TxMintValue buidl
-> BuildTxWith buidl (Map PolicyId (ScriptWitness WitCtxMint))
txMintValueScriptWitnesses} <-
  Cardano.Api.TxMintValue _ txMintValueInEra txMintValueScriptWitnesses
  where
    TxMintValue =
      MaryEraOnwards Era
-> Value
-> BuildTxWith buidl (Map PolicyId (ScriptWitness WitCtxMint))
-> TxMintValue buidl Era
forall era build.
MaryEraOnwards era
-> Value
-> BuildTxWith build (Map PolicyId (ScriptWitness WitCtxMint era))
-> TxMintValue build era
Cardano.Api.TxMintValue MaryEraOnwards Era
forall era. IsMaryBasedEra era => MaryEraOnwards era
maryBasedEra
-- ** TxOut

type TxOut ctx = Cardano.Api.TxOut ctx Era
{-# COMPLETE TxOut #-}

-- | TxOut specialized for 'Era'
pattern TxOut :: AddressInEra -> Value -> TxOutDatum ctx -> ReferenceScript -> TxOut ctx
pattern $mTxOut :: forall {r} {ctx}.
TxOut ctx
-> (AddressInEra
    -> Value -> TxOutDatum ctx -> ReferenceScript -> r)
-> ((# #) -> r)
-> r
$bTxOut :: forall ctx.
AddressInEra
-> Value -> TxOutDatum ctx -> ReferenceScript -> TxOut ctx
TxOut{forall ctx. TxOut ctx -> AddressInEra
txOutAddress, forall ctx. TxOut ctx -> Value
txOutValue, forall ctx. TxOut ctx -> TxOutDatum ctx
txOutDatum, forall ctx. TxOut ctx -> ReferenceScript
txOutReferenceScript} <-
  Cardano.Api.TxOut
    txOutAddress
    (TxOutValueShelleyBased _ (Extras.fromLedgerValue -> txOutValue))
    txOutDatum
    txOutReferenceScript
  where
    TxOut AddressInEra
addr Value
value TxOutDatum ctx
datum ReferenceScript
ref =
      AddressInEra
-> TxOutValue Era
-> TxOutDatum ctx
-> ReferenceScript
-> TxOut ctx Era
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
Cardano.Api.TxOut
        AddressInEra
addr
        (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
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra (Value -> MaryValue StandardCrypto
Extras.toLedgerValue Value
value))
        TxOutDatum ctx
datum
        ReferenceScript
ref

-- ** ReferenceScript

type ReferenceScript = Cardano.Api.Shelley.ReferenceScript Era
{-# COMPLETE ReferenceScript, ReferenceScriptNone #-}

pattern ReferenceScript :: ScriptInAnyLang -> ReferenceScript
pattern $mReferenceScript :: forall {r}.
ReferenceScript -> (ScriptInAnyLang -> r) -> ((# #) -> r) -> r
$bReferenceScript :: ScriptInAnyLang -> ReferenceScript
ReferenceScript{ReferenceScript -> ScriptInAnyLang
referenceScript} <-
  Cardano.Api.Shelley.ReferenceScript
    _
    referenceScript
  where
    ReferenceScript =
      BabbageEraOnwards Era -> ScriptInAnyLang -> ReferenceScript
forall era.
BabbageEraOnwards era -> ScriptInAnyLang -> ReferenceScript era
Cardano.Api.Shelley.ReferenceScript
        BabbageEraOnwards Era
forall era. IsBabbageBasedEra era => BabbageEraOnwards era
babbageBasedEra

pattern ReferenceScriptNone :: Cardano.Api.Shelley.ReferenceScript Era
pattern $mReferenceScriptNone :: forall {r}. ReferenceScript -> ((# #) -> r) -> ((# #) -> r) -> r
$bReferenceScriptNone :: ReferenceScript
ReferenceScriptNone <-
  Cardano.Api.Shelley.ReferenceScriptNone
  where
    ReferenceScriptNone =
      ReferenceScript
forall era. ReferenceScript era
Cardano.Api.Shelley.ReferenceScriptNone

-- ** TxOutDatum

type TxOutDatum ctx = Cardano.Api.TxOutDatum ctx Era
{-# COMPLETE TxOutDatumNone, TxOutDatumHash, TxOutDatumInTx, TxOutDatumInline #-}

pattern TxOutDatumNone :: TxOutDatum ctx
pattern $mTxOutDatumNone :: forall {r} {ctx}.
TxOutDatum ctx -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxOutDatumNone :: forall ctx. TxOutDatum ctx
TxOutDatumNone <-
  Cardano.Api.TxOutDatumNone
  where
    TxOutDatumNone =
      TxOutDatum ctx Era
forall ctx era. TxOutDatum ctx era
Cardano.Api.TxOutDatumNone

pattern TxOutDatumHash :: Hash ScriptData -> TxOutDatum ctx
pattern $mTxOutDatumHash :: forall {r} {ctx}.
TxOutDatum ctx -> (Hash ScriptData -> r) -> ((# #) -> r) -> r
$bTxOutDatumHash :: forall ctx. Hash ScriptData -> TxOutDatum ctx
TxOutDatumHash{forall ctx. TxOutDatum ctx -> Hash ScriptData
txOutDatumHash} <-
  Cardano.Api.TxOutDatumHash _ txOutDatumHash
  where
    TxOutDatumHash =
      AlonzoEraOnwards Era -> Hash ScriptData -> TxOutDatum ctx Era
forall era ctx.
AlonzoEraOnwards era -> Hash ScriptData -> TxOutDatum ctx era
Cardano.Api.TxOutDatumHash AlonzoEraOnwards Era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra

pattern TxOutDatumInTx :: HashableScriptData -> TxOutDatum CtxTx
pattern $mTxOutDatumInTx :: forall {r}.
TxOutDatum CtxTx -> (ScriptRedeemer -> r) -> ((# #) -> r) -> r
$bTxOutDatumInTx :: ScriptRedeemer -> TxOutDatum CtxTx
TxOutDatumInTx{TxOutDatum CtxTx -> ScriptRedeemer
txOutDatumScriptData} <-
  Cardano.Api.TxOutDatumInTx _ txOutDatumScriptData
  where
    TxOutDatumInTx =
      AlonzoEraOnwards Era -> ScriptRedeemer -> TxOutDatum CtxTx
forall era.
AlonzoEraOnwards era -> ScriptRedeemer -> TxOutDatum CtxTx era
Cardano.Api.TxOutDatumInTx AlonzoEraOnwards Era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra

pattern TxOutDatumInline :: HashableScriptData -> TxOutDatum ctx
pattern $mTxOutDatumInline :: forall {r} {ctx}.
TxOutDatum ctx -> (ScriptRedeemer -> r) -> ((# #) -> r) -> r
$bTxOutDatumInline :: forall ctx. ScriptRedeemer -> TxOutDatum ctx
TxOutDatumInline{forall ctx. TxOutDatum ctx -> ScriptRedeemer
txOutDatumInlineScriptData} <-
  Cardano.Api.TxOutDatumInline _ txOutDatumInlineScriptData
  where
    TxOutDatumInline =
      BabbageEraOnwards Era -> ScriptRedeemer -> TxOutDatum ctx Era
forall era ctx.
BabbageEraOnwards era -> ScriptRedeemer -> TxOutDatum ctx era
Cardano.Api.TxOutDatumInline BabbageEraOnwards Era
forall era. IsBabbageBasedEra era => BabbageEraOnwards era
babbageBasedEra

-- ** TxScriptValidity

type TxScriptValidity = Cardano.Api.TxScriptValidity Era
{-# COMPLETE TxScriptValidityNone, TxScriptValidity #-}

pattern TxScriptValidityNone :: TxScriptValidity
pattern $mTxScriptValidityNone :: forall {r}. TxScriptValidity -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxScriptValidityNone :: TxScriptValidity
TxScriptValidityNone <-
  Cardano.Api.TxScriptValidityNone
  where
    TxScriptValidityNone =
      TxScriptValidity
forall era. TxScriptValidity era
Cardano.Api.TxScriptValidityNone

pattern TxScriptValidity :: ScriptValidity -> TxScriptValidity
pattern $mTxScriptValidity :: forall {r}.
TxScriptValidity -> (ScriptValidity -> r) -> ((# #) -> r) -> r
$bTxScriptValidity :: ScriptValidity -> TxScriptValidity
TxScriptValidity{TxScriptValidity -> ScriptValidity
txScriptValidity'} <-
  Cardano.Api.TxScriptValidity _ txScriptValidity'
  where
    TxScriptValidity =
      AlonzoEraOnwards Era -> ScriptValidity -> TxScriptValidity
forall era.
AlonzoEraOnwards era -> ScriptValidity -> TxScriptValidity era
Cardano.Api.TxScriptValidity AlonzoEraOnwards Era
forall era. IsAlonzoBasedEra era => AlonzoEraOnwards era
alonzoBasedEra

-- ** TxValidityLowerBound

type TxValidityLowerBound = Cardano.Api.TxValidityLowerBound Era
{-# COMPLETE TxValidityNoLowerBound, TxValidityLowerBound #-}

pattern TxValidityNoLowerBound :: TxValidityLowerBound
pattern $mTxValidityNoLowerBound :: forall {r}.
TxValidityLowerBound -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxValidityNoLowerBound :: TxValidityLowerBound
TxValidityNoLowerBound <-
  Cardano.Api.TxValidityNoLowerBound
  where
    TxValidityNoLowerBound =
      TxValidityLowerBound
forall era. TxValidityLowerBound era
Cardano.Api.TxValidityNoLowerBound

pattern TxValidityLowerBound :: SlotNo -> TxValidityLowerBound
pattern $mTxValidityLowerBound :: forall {r}.
TxValidityLowerBound -> (SlotNo -> r) -> ((# #) -> r) -> r
$bTxValidityLowerBound :: SlotNo -> TxValidityLowerBound
TxValidityLowerBound{TxValidityLowerBound -> SlotNo
lowerBound} <-
  Cardano.Api.TxValidityLowerBound _ lowerBound
  where
    TxValidityLowerBound =
      AllegraEraOnwards Era -> SlotNo -> TxValidityLowerBound
forall era.
AllegraEraOnwards era -> SlotNo -> TxValidityLowerBound era
Cardano.Api.TxValidityLowerBound AllegraEraOnwards Era
forall era. IsAllegraBasedEra era => AllegraEraOnwards era
allegraBasedEra

-- ** TxValidityUpperBound

type TxValidityUpperBound = Cardano.Api.TxValidityUpperBound Era
{-# COMPLETE TxValidityNoUpperBound, TxValidityUpperBound #-}

pattern TxValidityNoUpperBound :: TxValidityUpperBound
pattern $mTxValidityNoUpperBound :: forall {r}.
TxValidityUpperBound -> ((# #) -> r) -> ((# #) -> r) -> r
$bTxValidityNoUpperBound :: TxValidityUpperBound
TxValidityNoUpperBound <-
  Cardano.Api.TxValidityUpperBound _ Nothing
  where
    TxValidityNoUpperBound =
      ShelleyBasedEra Era -> Maybe SlotNo -> TxValidityUpperBound
forall era.
ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
Cardano.Api.TxValidityUpperBound ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra Maybe SlotNo
forall a. Maybe a
Nothing

pattern TxValidityUpperBound :: SlotNo -> TxValidityUpperBound
pattern $mTxValidityUpperBound :: forall {r}.
TxValidityUpperBound -> (SlotNo -> r) -> ((# #) -> r) -> r
$bTxValidityUpperBound :: SlotNo -> TxValidityUpperBound
TxValidityUpperBound{TxValidityUpperBound -> SlotNo
upperBound} <-
  Cardano.Api.TxValidityUpperBound _ (Just upperBound)
  where
    TxValidityUpperBound =
      ShelleyBasedEra Era -> Maybe SlotNo -> TxValidityUpperBound
forall era.
ShelleyBasedEra era -> Maybe SlotNo -> TxValidityUpperBound era
Cardano.Api.TxValidityUpperBound ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra (Maybe SlotNo -> TxValidityUpperBound)
-> (SlotNo -> Maybe SlotNo) -> SlotNo -> TxValidityUpperBound
forall b c a. (b -> c) -> (a -> b) -> a -> c
. SlotNo -> Maybe SlotNo
forall a. a -> Maybe a
Just

-- ** Witness

type Witness witCtx = Cardano.Api.Witness witCtx Era
{-# COMPLETE ScriptWitness, KeyWitness #-}

pattern KeyWitness :: KeyWitnessInCtx ctx -> Witness ctx
pattern $mKeyWitness :: forall {r} {ctx}.
Witness ctx -> (KeyWitnessInCtx ctx -> r) -> ((# #) -> r) -> r
$bKeyWitness :: forall ctx. KeyWitnessInCtx ctx -> Witness ctx
KeyWitness keyWitnessInCtx <-
  Cardano.Api.KeyWitness keyWitnessInCtx
  where
    KeyWitness = KeyWitnessInCtx ctx -> Witness ctx Era
forall witctx era. KeyWitnessInCtx witctx -> Witness witctx era
Cardano.Api.KeyWitness

pattern ScriptWitness :: ScriptWitnessInCtx ctx -> ScriptWitness ctx -> Witness ctx
pattern $mScriptWitness :: forall {r} {ctx}.
Witness ctx
-> (ScriptWitnessInCtx ctx -> ScriptWitness ctx -> r)
-> ((# #) -> r)
-> r
$bScriptWitness :: forall ctx.
ScriptWitnessInCtx ctx -> ScriptWitness ctx -> Witness ctx
ScriptWitness scriptWitnessInCtx scriptWitness <-
  Cardano.Api.ScriptWitness scriptWitnessInCtx scriptWitness
  where
    ScriptWitness = ScriptWitnessInCtx ctx -> ScriptWitness ctx Era -> Witness ctx Era
forall witctx era.
ScriptWitnessInCtx witctx
-> ScriptWitness witctx era -> Witness witctx era
Cardano.Api.ScriptWitness

makeShelleyKeyWitness :: TxBody -> ShelleyWitnessSigningKey -> KeyWitness
makeShelleyKeyWitness :: TxBody -> ShelleyWitnessSigningKey -> KeyWitness
makeShelleyKeyWitness = ShelleyBasedEra Era
-> TxBody -> ShelleyWitnessSigningKey -> KeyWitness
forall era.
ShelleyBasedEra era
-> TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era
Cardano.Api.makeShelleyKeyWitness ShelleyBasedEra Era
forall era. IsShelleyBasedEra era => ShelleyBasedEra era
shelleyBasedEra