{-# LANGUAGE DataKinds           #-}
{-# LANGUAGE GADTs               #-}
{-# LANGUAGE LambdaCase          #-}
{-# LANGUAGE NamedFieldPuns      #-}
{-# LANGUAGE RankNTypes          #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications    #-}
{-| Lenses for @cardano-api@ types
-}
module Convex.Lenses(
  -- * Tx body content lenses
  emptyTx,
  emptyTxOut,
  TxIn,
  txIns,
  txInsReference,
  txOuts,
  txMintValue,
  txFee,
  txFee',
  txValidityRange,
  txMetadata,
  txProtocolParams,
  txInsCollateral,
  txScriptValidity,
  txAuxScripts,
  txExtraKeyWits,

  -- * Prisms and Isos
  _TxMintValue,
  _TxInsReference,
  _Value,
  _TxOut,
  _TxOutValue,
  _ShelleyAddressInBabbageEra,
  _PaymentCredentialByKey,
  _ShelleyPaymentCredentialByKey,
  _PaymentCredentialByScript,
  _ShelleyPaymentCredentialByScript,
  _TxInsCollateral,
  _TxMetadata,
  _TxAuxScripts,
  _TxExtraKeyWitnesses,

  -- ** Validity intervals
  _TxValidityNoLowerBound,
  _TxValidityLowerBound,
  _TxValidityNoUpperBound,
  _TxValidityUpperBound,
  _TxValidityFiniteRange,

  -- ** Witnesses
  _KeyWitness,
  _ScriptWitness,
  _PlutusScriptWitnessV1,
  _PlutusScriptWitnessV2,

  -- ** Build tx
  _BuildTxWith,
  _ViewTx,

  -- * Ledger API types
  slot,
  _UTxOState,
  utxoState,

  -- * Addresses
  _AddressInEra,
  _Address,

  -- * Hashes
  _ScriptHash,
  _KeyHash,
  _PlutusPubKeyHash,
  _PaymentCredential,

  -- * Datums
  _TxOutDatumInline,
  _TxOutDatumInTx,
  _TxOutDatumHash,
  _ScriptData
) where

import           Cardano.Api                        (AddressInEra, AssetId,
                                                     BabbageEra, BuildTx,
                                                     BuildTxWith, CtxTx,
                                                     PolicyId, Quantity (..),
                                                     ScriptWitness, TxMintValue,
                                                     TxOut, TxOutDatum,
                                                     TxOutValue, Value, ViewTx,
                                                     WitCtxMint)
import           Cardano.Api.Shelley                (Address, ReferenceScript,
                                                     ShelleyAddr, SlotNo)
import qualified Cardano.Api.Shelley                as C
import qualified Cardano.Ledger.BaseTypes           as Shelley
import qualified Cardano.Ledger.Core                as Core
import qualified Cardano.Ledger.Credential          as Credential
import           Cardano.Ledger.Crypto              (StandardCrypto)
import qualified Cardano.Ledger.Hashes              as Hashes
import qualified Cardano.Ledger.Keys                as Keys
import           Cardano.Ledger.Shelley.API         (Coin, LedgerEnv (..), UTxO,
                                                     UTxOState (..))
import           Cardano.Ledger.Shelley.Governance  (EraGovernance (GovernanceState))
import           Cardano.Ledger.Shelley.LedgerState (LedgerState (..),
                                                     updateStakeDistribution)
import           Control.Lens                       (Iso', Lens', Prism', iso,
                                                     lens, prism')
import qualified Convex.Scripts                     as Scripts
import           Data.Map.Strict                    (Map)
import qualified Data.Map.Strict                    as Map
import           Data.Proxy                         (Proxy (..))
import           Data.Word                          (Word64)
import           PlutusLedgerApi.V1                 (PubKeyHash (..))
import qualified PlutusLedgerApi.V1                 as PV1
import qualified PlutusTx.Prelude                   as PlutusTx

{-| 'TxBodyContent' with all fields set to empty, none, default values
-}
emptyTx :: C.TxBodyContent C.BuildTx BabbageEra
emptyTx :: TxBodyContent BuildTx BabbageEra
emptyTx =
  C.TxBodyContent
    { txIns :: TxIns BuildTx BabbageEra
C.txIns = []
    , txInsCollateral :: TxInsCollateral BabbageEra
C.txInsCollateral = forall era. TxInsCollateral era
C.TxInsCollateralNone
    , txInsReference :: TxInsReference BuildTx BabbageEra
C.txInsReference = forall build era. TxInsReference build era
C.TxInsReferenceNone
    , txOuts :: [TxOut CtxTx BabbageEra]
C.txOuts = []
    , txTotalCollateral :: TxTotalCollateral BabbageEra
C.txTotalCollateral = forall era. TxTotalCollateral era
C.TxTotalCollateralNone
    , txReturnCollateral :: TxReturnCollateral CtxTx BabbageEra
C.txReturnCollateral = forall ctx era. TxReturnCollateral ctx era
C.TxReturnCollateralNone
    , txFee :: TxFee BabbageEra
C.txFee = forall era. TxFeesExplicitInEra era -> Lovelace -> TxFee era
C.TxFeeExplicit TxFeesExplicitInEra BabbageEra
C.TxFeesExplicitInBabbageEra Lovelace
0
    , txValidityRange :: (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
C.txValidityRange = (forall era. TxValidityLowerBound era
C.TxValidityNoLowerBound, forall era.
ValidityNoUpperBoundSupportedInEra era -> TxValidityUpperBound era
C.TxValidityNoUpperBound ValidityNoUpperBoundSupportedInEra BabbageEra
C.ValidityNoUpperBoundInBabbageEra)
    , txMetadata :: TxMetadataInEra BabbageEra
C.txMetadata = forall era. TxMetadataInEra era
C.TxMetadataNone
    , txAuxScripts :: TxAuxScripts BabbageEra
C.txAuxScripts = forall era. TxAuxScripts era
C.TxAuxScriptsNone
    , txExtraKeyWits :: TxExtraKeyWitnesses BabbageEra
C.txExtraKeyWits = forall era. TxExtraKeyWitnesses era
C.TxExtraKeyWitnessesNone
    , txProtocolParams :: BuildTxWith BuildTx (Maybe ProtocolParameters)
C.txProtocolParams = forall a. a -> BuildTxWith BuildTx a
C.BuildTxWith forall a. Maybe a
Nothing
    , txWithdrawals :: TxWithdrawals BuildTx BabbageEra
C.txWithdrawals = forall build era. TxWithdrawals build era
C.TxWithdrawalsNone
    , txCertificates :: TxCertificates BuildTx BabbageEra
C.txCertificates = forall build era. TxCertificates build era
C.TxCertificatesNone
    , txUpdateProposal :: TxUpdateProposal BabbageEra
C.txUpdateProposal = forall era. TxUpdateProposal era
C.TxUpdateProposalNone
    , txMintValue :: TxMintValue BuildTx BabbageEra
C.txMintValue = forall build era. TxMintValue build era
C.TxMintNone
    , txScriptValidity :: TxScriptValidity BabbageEra
C.txScriptValidity = forall era. TxScriptValidity era
C.TxScriptValidityNone
    , txGovernanceActions :: TxGovernanceActions BabbageEra
C.txGovernanceActions = forall era. TxGovernanceActions era
C.TxGovernanceActionsNone
    , txVotes :: TxVotes BabbageEra
C.txVotes = forall era. TxVotes era
C.TxVotesNone
    }

{-| A transaction output with no value
-}
emptyTxOut :: AddressInEra BabbageEra -> C.TxOut C.CtxTx C.BabbageEra
emptyTxOut :: AddressInEra BabbageEra -> TxOut CtxTx BabbageEra
emptyTxOut AddressInEra BabbageEra
addr = forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
C.TxOut AddressInEra BabbageEra
addr (forall era. IsCardanoEra era => Lovelace -> TxOutValue era
C.lovelaceToTxOutValue Lovelace
0) forall ctx era. TxOutDatum ctx era
C.TxOutDatumNone forall era. ReferenceScript era
C.ReferenceScriptNone

type TxIn v = (C.TxIn, BuildTxWith v (C.Witness C.WitCtxTxIn BabbageEra))

txIns :: Lens' (C.TxBodyContent v BabbageEra) [TxIn v]
txIns :: forall v. Lens' (TxBodyContent v BabbageEra) [TxIn v]
txIns = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}. TxBodyContent build era -> TxIns build era
get forall {build} {era}.
TxBodyContent build era
-> TxIns build era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxIns build era
get = forall {build} {era}. TxBodyContent build era -> TxIns build era
C.txIns
  set_ :: TxBodyContent build era
-> TxIns build era -> TxBodyContent build era
set_ TxBodyContent build era
body TxIns build era
txIns' = TxBodyContent build era
body{txIns :: TxIns build era
C.txIns=TxIns build era
txIns'}

txInsReference :: Lens' (C.TxBodyContent v BabbageEra) (C.TxInsReference v BabbageEra)
txInsReference :: forall v.
Lens' (TxBodyContent v BabbageEra) (TxInsReference v BabbageEra)
txInsReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era -> TxInsReference build era
get forall {build} {era}.
TxBodyContent build era
-> TxInsReference build era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxInsReference build era
get = forall {build} {era}.
TxBodyContent build era -> TxInsReference build era
C.txInsReference
  set_ :: TxBodyContent build era
-> TxInsReference build era -> TxBodyContent build era
set_ TxBodyContent build era
body TxInsReference build era
txInsRef' = TxBodyContent build era
body{txInsReference :: TxInsReference build era
C.txInsReference = TxInsReference build era
txInsRef'}

-- Lenses for working with cardano-api transactions
txOuts :: Lens' (C.TxBodyContent v BabbageEra) [TxOut CtxTx BabbageEra]
txOuts :: forall v.
Lens' (TxBodyContent v BabbageEra) [TxOut CtxTx BabbageEra]
txOuts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}. TxBodyContent build era -> [TxOut CtxTx era]
get forall {build} {era}.
TxBodyContent build era
-> [TxOut CtxTx era] -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> [TxOut CtxTx era]
get = forall {build} {era}. TxBodyContent build era -> [TxOut CtxTx era]
C.txOuts
  set_ :: TxBodyContent build era
-> [TxOut CtxTx era] -> TxBodyContent build era
set_ TxBodyContent build era
body [TxOut CtxTx era]
txOuts' = TxBodyContent build era
body{txOuts :: [TxOut CtxTx era]
C.txOuts=[TxOut CtxTx era]
txOuts'}

txFee' :: Lens' (C.TxBodyContent v e) (C.TxFee e)
txFee' :: forall v e. Lens' (TxBodyContent v e) (TxFee e)
txFee' = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}. TxBodyContent build era -> TxFee era
get forall {build} {era}.
TxBodyContent build era -> TxFee era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxFee era
get           = forall {build} {era}. TxBodyContent build era -> TxFee era
C.txFee
  set_ :: TxBodyContent build era -> TxFee era -> TxBodyContent build era
set_ TxBodyContent build era
body TxFee era
fee = TxBodyContent build era
body{txFee :: TxFee era
C.txFee = TxFee era
fee}

txValidityRange :: Lens' (C.TxBodyContent v e) (C.TxValidityLowerBound e, C.TxValidityUpperBound e)
txValidityRange :: forall v e.
Lens'
  (TxBodyContent v e)
  (TxValidityLowerBound e, TxValidityUpperBound e)
txValidityRange = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
get forall {build} {era}.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
-> TxBodyContent build era
set_ where
  get :: TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
get = forall {build} {era}.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
C.txValidityRange
  set_ :: TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
-> TxBodyContent build era
set_ TxBodyContent build era
body (TxValidityLowerBound era, TxValidityUpperBound era)
range = TxBodyContent build era
body{txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
C.txValidityRange = (TxValidityLowerBound era, TxValidityUpperBound era)
range}

txFee :: Lens' (C.TxBodyContent v BabbageEra) C.Lovelace
txFee :: forall v. Lens' (TxBodyContent v BabbageEra) Lovelace
txFee = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall v. TxBodyContent v BabbageEra -> Lovelace
get forall {build}.
TxBodyContent build BabbageEra
-> Lovelace -> TxBodyContent build BabbageEra
set_ where
  get :: C.TxBodyContent v BabbageEra -> C.Lovelace
  get :: forall v. TxBodyContent v BabbageEra -> Lovelace
get TxBodyContent v BabbageEra
b = case forall {build} {era}. TxBodyContent build era -> TxFee era
C.txFee TxBodyContent v BabbageEra
b of { C.TxFeeExplicit TxFeesExplicitInEra BabbageEra
C.TxFeesExplicitInBabbageEra Lovelace
t_fee -> Lovelace
t_fee; C.TxFeeImplicit{} -> forall a. HasCallStack => [Char] -> a
error [Char]
"not possible in babbage era" }
  set_ :: TxBodyContent build BabbageEra
-> Lovelace -> TxBodyContent build BabbageEra
set_ TxBodyContent build BabbageEra
body Lovelace
fee = TxBodyContent build BabbageEra
body{txFee :: TxFee BabbageEra
C.txFee = forall era. TxFeesExplicitInEra era -> Lovelace -> TxFee era
C.TxFeeExplicit TxFeesExplicitInEra BabbageEra
C.TxFeesExplicitInBabbageEra Lovelace
fee}

txProtocolParams :: Lens' (C.TxBodyContent v e) (BuildTxWith v (Maybe C.ProtocolParameters))
txProtocolParams :: forall v e.
Lens'
  (TxBodyContent v e) (BuildTxWith v (Maybe ProtocolParameters))
txProtocolParams = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
get forall {build} {era}.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
-> TxBodyContent build era
set_ where
  get :: TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
get = forall {build} {era}.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
C.txProtocolParams
  set_ :: TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
-> TxBodyContent build era
set_ TxBodyContent build era
body BuildTxWith build (Maybe ProtocolParameters)
params = TxBodyContent build era
body{txProtocolParams :: BuildTxWith build (Maybe ProtocolParameters)
C.txProtocolParams = BuildTxWith build (Maybe ProtocolParameters)
params}

txMintValue :: Lens' (C.TxBodyContent v BabbageEra) (TxMintValue v BabbageEra)
txMintValue :: forall v.
Lens' (TxBodyContent v BabbageEra) (TxMintValue v BabbageEra)
txMintValue = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era -> TxMintValue build era
get forall {build} {era}.
TxBodyContent build era
-> TxMintValue build era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxMintValue build era
get = forall {build} {era}.
TxBodyContent build era -> TxMintValue build era
C.txMintValue
  set_ :: TxBodyContent build era
-> TxMintValue build era -> TxBodyContent build era
set_ TxBodyContent build era
body TxMintValue build era
txMintValue' = TxBodyContent build era
body{txMintValue :: TxMintValue build era
C.txMintValue=TxMintValue build era
txMintValue'}

txScriptValidity :: Lens' (C.TxBodyContent v e) (C.TxScriptValidity e)
txScriptValidity :: forall v e. Lens' (TxBodyContent v e) (TxScriptValidity e)
txScriptValidity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era -> TxScriptValidity era
get forall {build} {era}.
TxBodyContent build era
-> TxScriptValidity era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxScriptValidity era
get = forall {build} {era}.
TxBodyContent build era -> TxScriptValidity era
C.txScriptValidity
  set_ :: TxBodyContent build era
-> TxScriptValidity era -> TxBodyContent build era
set_ TxBodyContent build era
body TxScriptValidity era
v = TxBodyContent build era
body{txScriptValidity :: TxScriptValidity era
C.txScriptValidity = TxScriptValidity era
v}

txInsCollateral :: Lens' (C.TxBodyContent v BabbageEra) (C.TxInsCollateral BabbageEra)
txInsCollateral :: forall v.
Lens' (TxBodyContent v BabbageEra) (TxInsCollateral BabbageEra)
txInsCollateral = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era -> TxInsCollateral era
get forall {build} {era}.
TxBodyContent build era
-> TxInsCollateral era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxInsCollateral era
get = forall {build} {era}.
TxBodyContent build era -> TxInsCollateral era
C.txInsCollateral
  set_ :: TxBodyContent build era
-> TxInsCollateral era -> TxBodyContent build era
set_ TxBodyContent build era
body TxInsCollateral era
col = TxBodyContent build era
body{txInsCollateral :: TxInsCollateral era
C.txInsCollateral = TxInsCollateral era
col}

txMetadata :: Lens' (C.TxBodyContent v BabbageEra) (C.TxMetadataInEra BabbageEra)
txMetadata :: forall v.
Lens' (TxBodyContent v BabbageEra) (TxMetadataInEra BabbageEra)
txMetadata = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era -> TxMetadataInEra era
get forall {build} {era}.
TxBodyContent build era
-> TxMetadataInEra era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxMetadataInEra era
get = forall {build} {era}.
TxBodyContent build era -> TxMetadataInEra era
C.txMetadata
  set_ :: TxBodyContent build era
-> TxMetadataInEra era -> TxBodyContent build era
set_ TxBodyContent build era
body TxMetadataInEra era
m = TxBodyContent build era
body{txMetadata :: TxMetadataInEra era
C.txMetadata=TxMetadataInEra era
m}

txExtraKeyWits :: Lens' (C.TxBodyContent v BabbageEra) (C.TxExtraKeyWitnesses BabbageEra)
txExtraKeyWits :: forall v.
Lens' (TxBodyContent v BabbageEra) (TxExtraKeyWitnesses BabbageEra)
txExtraKeyWits = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}.
TxBodyContent build era -> TxExtraKeyWitnesses era
get forall {build} {era}.
TxBodyContent build era
-> TxExtraKeyWitnesses era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxExtraKeyWitnesses era
get = forall {build} {era}.
TxBodyContent build era -> TxExtraKeyWitnesses era
C.txExtraKeyWits
  set_ :: TxBodyContent build era
-> TxExtraKeyWitnesses era -> TxBodyContent build era
set_ TxBodyContent build era
body TxExtraKeyWitnesses era
k = TxBodyContent build era
body{txExtraKeyWits :: TxExtraKeyWitnesses era
C.txExtraKeyWits = TxExtraKeyWitnesses era
k}

_TxExtraKeyWitnesses :: Iso' (C.TxExtraKeyWitnesses BabbageEra) [C.Hash C.PaymentKey]
_TxExtraKeyWitnesses :: Iso' (TxExtraKeyWitnesses BabbageEra) [Hash PaymentKey]
_TxExtraKeyWitnesses = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso TxExtraKeyWitnesses BabbageEra -> [Hash PaymentKey]
from [Hash PaymentKey] -> TxExtraKeyWitnesses BabbageEra
to where
  from :: C.TxExtraKeyWitnesses BabbageEra -> [C.Hash C.PaymentKey]
  from :: TxExtraKeyWitnesses BabbageEra -> [Hash PaymentKey]
from TxExtraKeyWitnesses BabbageEra
C.TxExtraKeyWitnessesNone      = []
  from (C.TxExtraKeyWitnesses TxExtraKeyWitnessesSupportedInEra BabbageEra
_ [Hash PaymentKey]
keys) = [Hash PaymentKey]
keys

  to :: [Hash PaymentKey] -> TxExtraKeyWitnesses BabbageEra
to []   = forall era. TxExtraKeyWitnesses era
C.TxExtraKeyWitnessesNone
  to [Hash PaymentKey]
keys = forall era.
TxExtraKeyWitnessesSupportedInEra era
-> [Hash PaymentKey] -> TxExtraKeyWitnesses era
C.TxExtraKeyWitnesses TxExtraKeyWitnessesSupportedInEra BabbageEra
C.ExtraKeyWitnessesInBabbageEra [Hash PaymentKey]
keys

txAuxScripts :: Lens' (C.TxBodyContent v BabbageEra) (C.TxAuxScripts BabbageEra)
txAuxScripts :: forall v.
Lens' (TxBodyContent v BabbageEra) (TxAuxScripts BabbageEra)
txAuxScripts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {build} {era}. TxBodyContent build era -> TxAuxScripts era
get forall {build} {era}.
TxBodyContent build era
-> TxAuxScripts era -> TxBodyContent build era
set_ where
  get :: TxBodyContent build era -> TxAuxScripts era
get = forall {build} {era}. TxBodyContent build era -> TxAuxScripts era
C.txAuxScripts
  set_ :: TxBodyContent build era
-> TxAuxScripts era -> TxBodyContent build era
set_ TxBodyContent build era
body TxAuxScripts era
s = TxBodyContent build era
body{txAuxScripts :: TxAuxScripts era
C.txAuxScripts=TxAuxScripts era
s}

_TxAuxScripts :: Iso' (C.TxAuxScripts BabbageEra) [C.ScriptInEra BabbageEra]
_TxAuxScripts :: Iso' (TxAuxScripts BabbageEra) [ScriptInEra BabbageEra]
_TxAuxScripts = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso TxAuxScripts BabbageEra -> [ScriptInEra BabbageEra]
from [ScriptInEra BabbageEra] -> TxAuxScripts BabbageEra
to where
  from :: C.TxAuxScripts BabbageEra -> [C.ScriptInEra BabbageEra]
  from :: TxAuxScripts BabbageEra -> [ScriptInEra BabbageEra]
from = \case
    TxAuxScripts BabbageEra
C.TxAuxScriptsNone -> []
    C.TxAuxScripts AuxScriptsSupportedInEra BabbageEra
_ [ScriptInEra BabbageEra]
s -> [ScriptInEra BabbageEra]
s
  to :: [ScriptInEra BabbageEra] -> TxAuxScripts BabbageEra
to [ScriptInEra BabbageEra]
s | forall (t :: * -> *) a. Foldable t => t a -> Bool
null [ScriptInEra BabbageEra]
s = forall era. TxAuxScripts era
C.TxAuxScriptsNone
       | Bool
otherwise = forall era.
AuxScriptsSupportedInEra era
-> [ScriptInEra era] -> TxAuxScripts era
C.TxAuxScripts AuxScriptsSupportedInEra BabbageEra
C.AuxScriptsInBabbageEra [ScriptInEra BabbageEra]
s

_TxMetadata :: Iso' (C.TxMetadataInEra BabbageEra) (Map Word64 C.TxMetadataValue)
_TxMetadata :: Iso' (TxMetadataInEra BabbageEra) (Map Word64 TxMetadataValue)
_TxMetadata = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso TxMetadataInEra BabbageEra -> Map Word64 TxMetadataValue
from Map Word64 TxMetadataValue -> TxMetadataInEra BabbageEra
to where
  from :: C.TxMetadataInEra BabbageEra -> (Map Word64 C.TxMetadataValue)
  from :: TxMetadataInEra BabbageEra -> Map Word64 TxMetadataValue
from = \case
    TxMetadataInEra BabbageEra
C.TxMetadataNone                     -> forall k a. Map k a
Map.empty
    C.TxMetadataInEra TxMetadataSupportedInEra BabbageEra
_ (C.TxMetadata Map Word64 TxMetadataValue
m) -> Map Word64 TxMetadataValue
m
  to :: Map Word64 TxMetadataValue -> TxMetadataInEra BabbageEra
to Map Word64 TxMetadataValue
m | forall k a. Map k a -> Bool
Map.null Map Word64 TxMetadataValue
m = forall era. TxMetadataInEra era
C.TxMetadataNone
       | Bool
otherwise  = forall era.
TxMetadataSupportedInEra era -> TxMetadata -> TxMetadataInEra era
C.TxMetadataInEra TxMetadataSupportedInEra BabbageEra
C.TxMetadataInBabbageEra (Map Word64 TxMetadataValue -> TxMetadata
C.TxMetadata Map Word64 TxMetadataValue
m)

_TxInsCollateral :: Iso' (C.TxInsCollateral BabbageEra) [C.TxIn]
_TxInsCollateral :: Iso' (TxInsCollateral BabbageEra) [TxIn]
_TxInsCollateral = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso TxInsCollateral BabbageEra -> [TxIn]
from [TxIn] -> TxInsCollateral BabbageEra
to where
  from :: C.TxInsCollateral BabbageEra -> [C.TxIn]
  from :: TxInsCollateral BabbageEra -> [TxIn]
from = \case
    TxInsCollateral BabbageEra
C.TxInsCollateralNone  -> []
    C.TxInsCollateral CollateralSupportedInEra BabbageEra
_ [TxIn]
xs -> [TxIn]
xs
  to :: [TxIn] -> TxInsCollateral BabbageEra
to = \case
    [] -> forall era. TxInsCollateral era
C.TxInsCollateralNone
    [TxIn]
xs -> forall era.
CollateralSupportedInEra era -> [TxIn] -> TxInsCollateral era
C.TxInsCollateral CollateralSupportedInEra BabbageEra
C.CollateralInBabbageEra [TxIn]
xs

_TxMintValue :: Iso' (TxMintValue BuildTx BabbageEra) (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
_TxMintValue :: Iso'
  (TxMintValue BuildTx BabbageEra)
  (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
_TxMintValue = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso TxMintValue BuildTx BabbageEra
-> (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
from (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
-> TxMintValue BuildTx BabbageEra
to where
  from :: TxMintValue BuildTx BabbageEra -> (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
  from :: TxMintValue BuildTx BabbageEra
-> (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
from = \case
    TxMintValue BuildTx BabbageEra
C.TxMintNone                          -> (forall a. Monoid a => a
mempty, forall a. Monoid a => a
mempty)
    C.TxMintValue MultiAssetSupportedInEra BabbageEra
_ Value
vl (C.BuildTxWith Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
mp) -> (Value
vl, Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
mp)
  to :: (Value, Map PolicyId (ScriptWitness WitCtxMint BabbageEra))
-> TxMintValue BuildTx BabbageEra
to (Value
vl, Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
mp)
    | forall k a. Map k a -> Bool
Map.null Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
mp Bool -> Bool -> Bool
&& Value
vl forall a. Eq a => a -> a -> Bool
== forall a. Monoid a => a
mempty = forall build era. TxMintValue build era
C.TxMintNone
    | Bool
otherwise                   = forall era build.
MultiAssetSupportedInEra era
-> Value
-> BuildTxWith build (Map PolicyId (ScriptWitness WitCtxMint era))
-> TxMintValue build era
C.TxMintValue MultiAssetSupportedInEra BabbageEra
C.MultiAssetInBabbageEra Value
vl (forall a. a -> BuildTxWith BuildTx a
C.BuildTxWith Map PolicyId (ScriptWitness WitCtxMint BabbageEra)
mp)

_TxInsReference :: Iso' (C.TxInsReference build BabbageEra) [C.TxIn]
_TxInsReference :: forall build. Iso' (TxInsReference build BabbageEra) [TxIn]
_TxInsReference = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall build. TxInsReference build BabbageEra -> [TxIn]
from forall {build}. [TxIn] -> TxInsReference build BabbageEra
to where
  from :: C.TxInsReference build BabbageEra -> [C.TxIn]
  from :: forall build. TxInsReference build BabbageEra -> [TxIn]
from = \case
    TxInsReference build BabbageEra
C.TxInsReferenceNone   -> []
    C.TxInsReference ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
_ [TxIn]
ins -> [TxIn]
ins
  to :: [TxIn] -> TxInsReference build BabbageEra
to = \case
    [] -> forall build era. TxInsReference build era
C.TxInsReferenceNone
    [TxIn]
xs -> forall era build.
ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> [TxIn] -> TxInsReference build era
C.TxInsReference ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
C.ReferenceTxInsScriptsInlineDatumsInBabbageEra [TxIn]
xs


_Value :: Iso' Value (Map AssetId Quantity)
_Value :: Iso' Value (Map AssetId Quantity)
_Value = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso Value -> Map AssetId Quantity
from Map AssetId Quantity -> Value
to where
  -- the 'Value' constructor is not exposed so we have to take the long way around
  from :: Value -> Map AssetId Quantity
from = forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. Value -> [(AssetId, Quantity)]
C.valueToList
  to :: Map AssetId Quantity -> Value
to = [(AssetId, Quantity)] -> Value
C.valueFromList forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall k a. Map k a -> [(k, a)]
Map.toList

_TxOut :: Iso' (TxOut ctx era) (AddressInEra era, TxOutValue era, TxOutDatum ctx era, ReferenceScript era)
_TxOut :: forall ctx era.
Iso'
  (TxOut ctx era)
  (AddressInEra era, TxOutValue era, TxOutDatum ctx era,
   ReferenceScript era)
_TxOut = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall {ctx} {era}.
TxOut ctx era
-> (AddressInEra era, TxOutValue era, TxOutDatum ctx era,
    ReferenceScript era)
from forall {era} {ctx}.
(AddressInEra era, TxOutValue era, TxOutDatum ctx era,
 ReferenceScript era)
-> TxOut ctx era
to where
  from :: TxOut ctx era
-> (AddressInEra era, TxOutValue era, TxOutDatum ctx era,
    ReferenceScript era)
from (C.TxOut AddressInEra era
addr TxOutValue era
vl TxOutDatum ctx era
dt ReferenceScript era
rs) = (AddressInEra era
addr, TxOutValue era
vl, TxOutDatum ctx era
dt, ReferenceScript era
rs)
  to :: (AddressInEra era, TxOutValue era, TxOutDatum ctx era,
 ReferenceScript era)
-> TxOut ctx era
to (AddressInEra era
addr, TxOutValue era
vl, TxOutDatum ctx era
dt, ReferenceScript era
rs) = forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
C.TxOut AddressInEra era
addr TxOutValue era
vl TxOutDatum ctx era
dt ReferenceScript era
rs

_TxOutDatumHash :: Prism' (TxOutDatum ctx C.BabbageEra) (C.Hash C.ScriptData)
_TxOutDatumHash :: forall ctx. Prism' (TxOutDatum ctx BabbageEra) (Hash ScriptData)
_TxOutDatumHash = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall ctx. Hash ScriptData -> TxOutDatum ctx BabbageEra
from forall ctx. TxOutDatum ctx BabbageEra -> Maybe (Hash ScriptData)
to where
  to :: TxOutDatum ctx C.BabbageEra -> Maybe (C.Hash C.ScriptData)
  to :: forall ctx. TxOutDatum ctx BabbageEra -> Maybe (Hash ScriptData)
to (C.TxOutDatumHash ScriptDataSupportedInEra BabbageEra
_ Hash ScriptData
h) = forall a. a -> Maybe a
Just Hash ScriptData
h
  to TxOutDatum ctx BabbageEra
_                      = forall a. Maybe a
Nothing
  from :: C.Hash C.ScriptData -> TxOutDatum ctx C.BabbageEra
  from :: forall ctx. Hash ScriptData -> TxOutDatum ctx BabbageEra
from Hash ScriptData
h = forall era ctx.
ScriptDataSupportedInEra era
-> Hash ScriptData -> TxOutDatum ctx era
C.TxOutDatumHash ScriptDataSupportedInEra BabbageEra
C.ScriptDataInBabbageEra Hash ScriptData
h

_TxOutDatumInTx :: Prism' (TxOutDatum CtxTx C.BabbageEra) C.HashableScriptData
_TxOutDatumInTx :: Prism' (TxOutDatum CtxTx BabbageEra) HashableScriptData
_TxOutDatumInTx = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' HashableScriptData -> TxOutDatum CtxTx BabbageEra
from TxOutDatum CtxTx BabbageEra -> Maybe HashableScriptData
to where
  to :: TxOutDatum CtxTx C.BabbageEra -> Maybe C.HashableScriptData
  to :: TxOutDatum CtxTx BabbageEra -> Maybe HashableScriptData
to (C.TxOutDatumInTx ScriptDataSupportedInEra BabbageEra
_ HashableScriptData
k) = forall a. a -> Maybe a
Just HashableScriptData
k
  to TxOutDatum CtxTx BabbageEra
_                      = forall a. Maybe a
Nothing
  from :: C.HashableScriptData -> TxOutDatum CtxTx C.BabbageEra
  from :: HashableScriptData -> TxOutDatum CtxTx BabbageEra
from HashableScriptData
cd = forall era.
ScriptDataSupportedInEra era
-> HashableScriptData -> TxOutDatum CtxTx era
C.TxOutDatumInTx ScriptDataSupportedInEra BabbageEra
C.ScriptDataInBabbageEra HashableScriptData
cd

_TxOutDatumInline :: forall ctx. Prism' (TxOutDatum ctx C.BabbageEra) C.HashableScriptData
_TxOutDatumInline :: forall ctx. Prism' (TxOutDatum ctx BabbageEra) HashableScriptData
_TxOutDatumInline = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' HashableScriptData -> TxOutDatum ctx BabbageEra
from TxOutDatum ctx BabbageEra -> Maybe HashableScriptData
to where
  to :: TxOutDatum ctx C.BabbageEra -> Maybe C.HashableScriptData
  to :: TxOutDatum ctx BabbageEra -> Maybe HashableScriptData
to (C.TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
_ HashableScriptData
k) = forall a. a -> Maybe a
Just HashableScriptData
k
  to TxOutDatum ctx BabbageEra
_                        = forall a. Maybe a
Nothing
  from :: C.HashableScriptData -> TxOutDatum ctx C.BabbageEra
  from :: HashableScriptData -> TxOutDatum ctx BabbageEra
from HashableScriptData
cd = forall era ctx.
ReferenceTxInsScriptsInlineDatumsSupportedInEra era
-> HashableScriptData -> TxOutDatum ctx era
C.TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
C.ReferenceTxInsScriptsInlineDatumsInBabbageEra HashableScriptData
cd

_ShelleyAddressInBabbageEra :: Prism' (C.AddressInEra C.BabbageEra) (Shelley.Network, Credential.PaymentCredential StandardCrypto, Credential.StakeReference StandardCrypto)
_ShelleyAddressInBabbageEra :: Prism'
  (AddressInEra BabbageEra)
  (Network, PaymentCredential StandardCrypto,
   StakeReference StandardCrypto)
_ShelleyAddressInBabbageEra = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (Network, PaymentCredential StandardCrypto,
 StakeReference StandardCrypto)
-> AddressInEra BabbageEra
from AddressInEra BabbageEra
-> Maybe
     (Network, PaymentCredential StandardCrypto,
      StakeReference StandardCrypto)
to where
  to :: C.AddressInEra C.BabbageEra -> Maybe (Shelley.Network, Credential.PaymentCredential StandardCrypto, Credential.StakeReference StandardCrypto)
  to :: AddressInEra BabbageEra
-> Maybe
     (Network, PaymentCredential StandardCrypto,
      StakeReference StandardCrypto)
to AddressInEra BabbageEra
x = case AddressInEra BabbageEra
x of
    (C.AddressInEra (C.ShelleyAddressInEra ShelleyBasedEra BabbageEra
C.ShelleyBasedEraBabbage) (C.ShelleyAddress Network
ntw PaymentCredential StandardCrypto
pmt StakeReference StandardCrypto
stakeRef)) -> forall a. a -> Maybe a
Just (Network
ntw, PaymentCredential StandardCrypto
pmt, StakeReference StandardCrypto
stakeRef)
    (C.AddressInEra (AddressTypeInEra addrtype BabbageEra
C.ByronAddressInAnyEra) Address addrtype
_) -> forall a. Maybe a
Nothing
  from :: (Network, PaymentCredential StandardCrypto,
 StakeReference StandardCrypto)
-> AddressInEra BabbageEra
from (Network
ntw, PaymentCredential StandardCrypto
pmt, StakeReference StandardCrypto
stakeRef) = forall addrtype era.
AddressTypeInEra addrtype era
-> Address addrtype -> AddressInEra era
C.AddressInEra (forall era. ShelleyBasedEra era -> AddressTypeInEra ShelleyAddr era
C.ShelleyAddressInEra ShelleyBasedEra BabbageEra
C.ShelleyBasedEraBabbage) (Network
-> PaymentCredential StandardCrypto
-> StakeReference StandardCrypto
-> Address ShelleyAddr
C.ShelleyAddress Network
ntw PaymentCredential StandardCrypto
pmt StakeReference StandardCrypto
stakeRef)

_PaymentCredentialByKey :: Prism' C.PaymentCredential (C.Hash C.PaymentKey)
_PaymentCredentialByKey :: Prism' PaymentCredential (Hash PaymentKey)
_PaymentCredentialByKey = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' Hash PaymentKey -> PaymentCredential
from PaymentCredential -> Maybe (Hash PaymentKey)
to where
  from :: Hash PaymentKey -> PaymentCredential
from = Hash PaymentKey -> PaymentCredential
C.PaymentCredentialByKey
  to :: PaymentCredential -> Maybe (Hash PaymentKey)
to (C.PaymentCredentialByKey Hash PaymentKey
k) = forall a. a -> Maybe a
Just Hash PaymentKey
k
  to PaymentCredential
_                            = forall a. Maybe a
Nothing

_ShelleyPaymentCredentialByKey :: Prism' (Credential.PaymentCredential StandardCrypto) (Keys.KeyHash 'Keys.Payment StandardCrypto)
_ShelleyPaymentCredentialByKey :: Prism'
  (PaymentCredential StandardCrypto)
  (KeyHash 'Payment StandardCrypto)
_ShelleyPaymentCredentialByKey = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {kr :: KeyRole} {c}. KeyHash kr c -> Credential kr c
from forall {kr :: KeyRole} {c}. Credential kr c -> Maybe (KeyHash kr c)
to where
  from :: KeyHash kr c -> Credential kr c
from = forall {kr :: KeyRole} {c}. KeyHash kr c -> Credential kr c
Credential.KeyHashObj
  to :: Credential kr c -> Maybe (KeyHash kr c)
to (Credential.KeyHashObj KeyHash kr c
k)  = forall a. a -> Maybe a
Just KeyHash kr c
k
  to Credential.ScriptHashObj{} = forall a. Maybe a
Nothing

_PaymentCredentialByScript :: Prism' C.PaymentCredential C.ScriptHash
_PaymentCredentialByScript :: Prism' PaymentCredential ScriptHash
_PaymentCredentialByScript = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' ScriptHash -> PaymentCredential
from PaymentCredential -> Maybe ScriptHash
to where
  from :: ScriptHash -> PaymentCredential
from = ScriptHash -> PaymentCredential
C.PaymentCredentialByScript
  to :: PaymentCredential -> Maybe ScriptHash
to (C.PaymentCredentialByScript ScriptHash
k) = forall a. a -> Maybe a
Just ScriptHash
k
  to C.PaymentCredentialByKey{}      = forall a. Maybe a
Nothing

_ShelleyPaymentCredentialByScript :: Prism' (Credential.PaymentCredential StandardCrypto) (Hashes.ScriptHash StandardCrypto)
_ShelleyPaymentCredentialByScript :: Prism'
  (PaymentCredential StandardCrypto) (ScriptHash StandardCrypto)
_ShelleyPaymentCredentialByScript = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {c} {kr :: KeyRole}. ScriptHash c -> Credential kr c
from forall {kr :: KeyRole} {c}. Credential kr c -> Maybe (ScriptHash c)
to where
  from :: ScriptHash c -> Credential kr c
from = forall (kr :: KeyRole) c. ScriptHash c -> Credential kr c
Credential.ScriptHashObj
  to :: Credential kr c -> Maybe (ScriptHash c)
to (Credential.ScriptHashObj ScriptHash c
s) = forall a. a -> Maybe a
Just ScriptHash c
s
  to Credential.KeyHashObj{}      = forall a. Maybe a
Nothing

_KeyWitness :: Prism' (C.Witness witctx era) (C.KeyWitnessInCtx witctx)
_KeyWitness :: forall witctx era.
Prism' (Witness witctx era) (KeyWitnessInCtx witctx)
_KeyWitness = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {witctx} {era}. KeyWitnessInCtx witctx -> Witness witctx era
from forall witctx era.
Witness witctx era -> Maybe (KeyWitnessInCtx witctx)
to where
  from :: KeyWitnessInCtx witctx -> Witness witctx era
from = forall {witctx} {era}. KeyWitnessInCtx witctx -> Witness witctx era
C.KeyWitness
  to :: C.Witness witctx era -> Maybe (C.KeyWitnessInCtx witctx)
  to :: forall witctx era.
Witness witctx era -> Maybe (KeyWitnessInCtx witctx)
to = \case
    C.KeyWitness KeyWitnessInCtx witctx
w    -> forall a. a -> Maybe a
Just KeyWitnessInCtx witctx
w
    C.ScriptWitness{} -> forall a. Maybe a
Nothing

_ScriptWitness :: Prism' (C.Witness witctx era) (C.ScriptWitnessInCtx witctx, C.ScriptWitness witctx era)
_ScriptWitness :: forall witctx era.
Prism'
  (Witness witctx era)
  (ScriptWitnessInCtx witctx, ScriptWitness witctx era)
_ScriptWitness = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {witctx} {era}.
(ScriptWitnessInCtx witctx, ScriptWitness witctx era)
-> Witness witctx era
from forall witctx era.
Witness witctx era
-> Maybe (ScriptWitnessInCtx witctx, ScriptWitness witctx era)
to where
  from :: (ScriptWitnessInCtx witctx, ScriptWitness witctx era)
-> Witness witctx era
from (ScriptWitnessInCtx witctx
a, ScriptWitness witctx era
b) = forall witctx era.
ScriptWitnessInCtx witctx
-> ScriptWitness witctx era -> Witness witctx era
C.ScriptWitness ScriptWitnessInCtx witctx
a ScriptWitness witctx era
b
  to :: C.Witness witctx era -> Maybe (C.ScriptWitnessInCtx witctx, C.ScriptWitness witctx era)
  to :: forall witctx era.
Witness witctx era
-> Maybe (ScriptWitnessInCtx witctx, ScriptWitness witctx era)
to = \case
    C.ScriptWitness ScriptWitnessInCtx witctx
a ScriptWitness witctx era
b -> forall a. a -> Maybe a
Just (ScriptWitnessInCtx witctx
a, ScriptWitness witctx era
b)
    C.KeyWitness{}      -> forall a. Maybe a
Nothing

_ViewTx :: Iso' (C.BuildTxWith ViewTx a) ()
_ViewTx :: forall a. Iso' (BuildTxWith ViewTx a) ()
_ViewTx = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall a. BuildTxWith ViewTx a -> ()
from forall {a}. () -> BuildTxWith ViewTx a
to where
  from :: C.BuildTxWith ViewTx a -> ()
  from :: forall a. BuildTxWith ViewTx a -> ()
from = \case
    C.ViewTx{} -> ()
  to :: () -> BuildTxWith ViewTx a
to () = C.ViewTx{}

_BuildTxWith :: Iso' (C.BuildTxWith BuildTx a) a
_BuildTxWith :: forall a. Iso' (BuildTxWith BuildTx a) a
_BuildTxWith = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall a. BuildTxWith BuildTx a -> a
from forall a. a -> BuildTxWith BuildTx a
to where
  from :: C.BuildTxWith BuildTx a -> a
  from :: forall a. BuildTxWith BuildTx a -> a
from = \case
    C.BuildTxWith a
a -> a
a
  to :: a -> BuildTxWith BuildTx a
to = forall a. a -> BuildTxWith BuildTx a
C.BuildTxWith

_TxOutValue :: Iso' (TxOutValue BabbageEra) Value
_TxOutValue :: Iso' (TxOutValue BabbageEra) Value
_TxOutValue = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall {era}. TxOutValue era -> Value
from Value -> TxOutValue BabbageEra
to where
  from :: TxOutValue era -> Value
from = forall {era}. TxOutValue era -> Value
C.txOutValueToValue
  to :: Value -> TxOutValue BabbageEra
to = forall era. MultiAssetSupportedInEra era -> Value -> TxOutValue era
C.TxOutValue MultiAssetSupportedInEra BabbageEra
C.MultiAssetInBabbageEra

slot :: Lens' (LedgerEnv era) SlotNo
slot :: forall era. Lens' (LedgerEnv era) SlotNo
slot = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {era}. LedgerEnv era -> SlotNo
get forall {era}. LedgerEnv era -> SlotNo -> LedgerEnv era
set_ where
  get :: LedgerEnv era -> SlotNo
get = forall {era}. LedgerEnv era -> SlotNo
ledgerSlotNo
  set_ :: LedgerEnv era -> SlotNo -> LedgerEnv era
set_ LedgerEnv era
l SlotNo
s = LedgerEnv era
l{ledgerSlotNo :: SlotNo
ledgerSlotNo=SlotNo
s}

{-| 'UTxOState' iso. Note that this doesn't touch the '_stakeDistro' field. This is because the
stake distro is a function of @utxo :: UTxO era@ and can be computed by @updateStakeDistribution mempty mempty utxo@.
-}
_UTxOState :: forall era. (Core.EraTxOut era) => Core.PParams era -> Iso' (UTxOState era) (UTxO era, Coin, Coin, GovernanceState era)
_UTxOState :: forall era.
EraTxOut era =>
PParams era
-> Iso' (UTxOState era) (UTxO era, Coin, Coin, GovernanceState era)
_UTxOState PParams era
pp = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso forall {era}.
UTxOState era -> (UTxO era, Coin, Coin, GovernanceState era)
from (UTxO era, Coin, Coin, GovernanceState era) -> UTxOState era
to where
  from :: UTxOState era -> (UTxO era, Coin, Coin, GovernanceState era)
from UTxOState{UTxO era
utxosUtxo :: forall era. UTxOState era -> UTxO era
utxosUtxo :: UTxO era
utxosUtxo, Coin
utxosDeposited :: forall era. UTxOState era -> Coin
utxosDeposited :: Coin
utxosDeposited, Coin
utxosFees :: forall era. UTxOState era -> Coin
utxosFees :: Coin
utxosFees, GovernanceState era
utxosGovernance :: forall era. UTxOState era -> GovernanceState era
utxosGovernance :: GovernanceState era
utxosGovernance} = (UTxO era
utxosUtxo, Coin
utxosDeposited, Coin
utxosFees, GovernanceState era
utxosGovernance)
  to :: (UTxO era, Coin, Coin, GovernanceState era) -> UTxOState era
to (UTxO era
utxosUtxo, Coin
utxosDeposited, Coin
utxosFees, GovernanceState era
utxosGovernance) = UTxOState{UTxO era
utxosUtxo :: UTxO era
utxosUtxo :: UTxO era
utxosUtxo, Coin
utxosDeposited :: Coin
utxosDeposited :: Coin
utxosDeposited, Coin
utxosFees :: Coin
utxosFees :: Coin
utxosFees, GovernanceState era
utxosGovernance :: GovernanceState era
utxosGovernance :: GovernanceState era
utxosGovernance, utxosStakeDistr :: IncrementalStake (EraCrypto era)
utxosStakeDistr = forall era.
EraTxOut era =>
PParams era
-> IncrementalStake (EraCrypto era)
-> UTxO era
-> UTxO era
-> IncrementalStake (EraCrypto era)
updateStakeDistribution PParams era
pp forall a. Monoid a => a
mempty forall a. Monoid a => a
mempty UTxO era
utxosUtxo}


utxoState :: Lens' (LedgerState era) (UTxOState era)
utxoState :: forall era. Lens' (LedgerState era) (UTxOState era)
utxoState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens forall {era}. LedgerState era -> UTxOState era
get forall {era}. LedgerState era -> UTxOState era -> LedgerState era
set_ where
  get :: LedgerState era -> UTxOState era
get = forall {era}. LedgerState era -> UTxOState era
lsUTxOState
  set_ :: LedgerState era -> UTxOState era -> LedgerState era
set_ LedgerState era
l UTxOState era
s = LedgerState era
l{lsUTxOState :: UTxOState era
lsUTxOState=UTxOState era
s}

_AddressInEra :: Prism' (AddressInEra BabbageEra) (Address ShelleyAddr)
_AddressInEra :: Prism' (AddressInEra BabbageEra) (Address ShelleyAddr)
_AddressInEra = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' Address ShelleyAddr -> AddressInEra BabbageEra
from AddressInEra BabbageEra -> Maybe (Address ShelleyAddr)
to where
  to :: AddressInEra BabbageEra -> Maybe (Address ShelleyAddr)
  to :: AddressInEra BabbageEra -> Maybe (Address ShelleyAddr)
to (C.AddressInEra (C.ShelleyAddressInEra ShelleyBasedEra BabbageEra
C.ShelleyBasedEraBabbage) Address addrtype
addr) = forall a. a -> Maybe a
Just Address addrtype
addr
  to AddressInEra BabbageEra
_ = forall a. Maybe a
Nothing
  from :: Address ShelleyAddr -> AddressInEra BabbageEra
from = forall addrtype era.
AddressTypeInEra addrtype era
-> Address addrtype -> AddressInEra era
C.AddressInEra (forall era. ShelleyBasedEra era -> AddressTypeInEra ShelleyAddr era
C.ShelleyAddressInEra ShelleyBasedEra BabbageEra
C.ShelleyBasedEraBabbage)

_Address :: Iso' (Address ShelleyAddr) (Shelley.Network, Credential.PaymentCredential StandardCrypto, Credential.StakeReference StandardCrypto)
_Address :: Iso'
  (Address ShelleyAddr)
  (Network, PaymentCredential StandardCrypto,
   StakeReference StandardCrypto)
_Address = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso Address ShelleyAddr
-> (Network, PaymentCredential StandardCrypto,
    StakeReference StandardCrypto)
from (Network, PaymentCredential StandardCrypto,
 StakeReference StandardCrypto)
-> Address ShelleyAddr
to where
  from :: Address ShelleyAddr -> (Shelley.Network, Credential.PaymentCredential StandardCrypto, Credential.StakeReference StandardCrypto)
  from :: Address ShelleyAddr
-> (Network, PaymentCredential StandardCrypto,
    StakeReference StandardCrypto)
from (C.ShelleyAddress Network
n PaymentCredential StandardCrypto
p StakeReference StandardCrypto
s) = (Network
n, PaymentCredential StandardCrypto
p, StakeReference StandardCrypto
s)
  to :: (Network, PaymentCredential StandardCrypto,
 StakeReference StandardCrypto)
-> Address ShelleyAddr
to (Network
n, PaymentCredential StandardCrypto
p, StakeReference StandardCrypto
s) = Network
-> PaymentCredential StandardCrypto
-> StakeReference StandardCrypto
-> Address ShelleyAddr
C.ShelleyAddress Network
n PaymentCredential StandardCrypto
p StakeReference StandardCrypto
s

_KeyHash :: Iso' (Keys.KeyHash 'Keys.Payment StandardCrypto) (C.Hash C.PaymentKey)
_KeyHash :: Iso' (KeyHash 'Payment StandardCrypto) (Hash PaymentKey)
_KeyHash = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso KeyHash 'Payment StandardCrypto -> Hash PaymentKey
from Hash PaymentKey -> KeyHash 'Payment StandardCrypto
to where
  from :: Keys.KeyHash 'Keys.Payment StandardCrypto -> C.Hash C.PaymentKey
  from :: KeyHash 'Payment StandardCrypto -> Hash PaymentKey
from KeyHash 'Payment StandardCrypto
hash = KeyHash 'Payment StandardCrypto -> Hash PaymentKey
C.PaymentKeyHash KeyHash 'Payment StandardCrypto
hash
  to :: Hash PaymentKey -> KeyHash 'Payment StandardCrypto
to (C.PaymentKeyHash KeyHash 'Payment StandardCrypto
h) = KeyHash 'Payment StandardCrypto
h

_ScriptHash :: Iso' (Hashes.ScriptHash StandardCrypto) C.ScriptHash
_ScriptHash :: Iso' (ScriptHash StandardCrypto) ScriptHash
_ScriptHash = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso ScriptHash StandardCrypto -> ScriptHash
from ScriptHash -> ScriptHash StandardCrypto
to where
  from :: Hashes.ScriptHash StandardCrypto -> C.ScriptHash
  from :: ScriptHash StandardCrypto -> ScriptHash
from = ScriptHash StandardCrypto -> ScriptHash
C.fromShelleyScriptHash

  to :: C.ScriptHash -> Hashes.ScriptHash StandardCrypto
  to :: ScriptHash -> ScriptHash StandardCrypto
to = ScriptHash -> ScriptHash StandardCrypto
C.toShelleyScriptHash

_PlutusPubKeyHash :: Prism' PubKeyHash (C.Hash C.PaymentKey)
_PlutusPubKeyHash :: Prism' PubKeyHash (Hash PaymentKey)
_PlutusPubKeyHash = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' Hash PaymentKey -> PubKeyHash
from PubKeyHash -> Maybe (Hash PaymentKey)
to where
  from :: C.Hash C.PaymentKey -> PubKeyHash
  from :: Hash PaymentKey -> PubKeyHash
from = BuiltinByteString -> PubKeyHash
PubKeyHash forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a arep. ToBuiltin a arep => a -> arep
PlutusTx.toBuiltin forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. SerialiseAsRawBytes a => a -> ByteString
C.serialiseToRawBytes

  to :: PubKeyHash -> Maybe (C.Hash C.PaymentKey)
  to :: PubKeyHash -> Maybe (Hash PaymentKey)
to (PubKeyHash BuiltinByteString
h) = forall a c b. (a -> c) -> (b -> c) -> Either a b -> c
either (forall a b. a -> b -> a
const forall a. Maybe a
Nothing) forall a. a -> Maybe a
Just forall a b. (a -> b) -> a -> b
$ forall a.
SerialiseAsRawBytes a =>
AsType a -> ByteString -> Either SerialiseAsRawBytesError a
C.deserialiseFromRawBytes (forall t. HasTypeProxy t => Proxy t -> AsType t
C.proxyToAsType forall a b. (a -> b) -> a -> b
$ forall {k} (t :: k). Proxy t
Proxy @(C.Hash C.PaymentKey)) forall a b. (a -> b) -> a -> b
$ forall arep a. FromBuiltin arep a => arep -> a
PlutusTx.fromBuiltin BuiltinByteString
h

_PaymentCredential :: Iso' C.PaymentCredential (Credential.PaymentCredential StandardCrypto)
_PaymentCredential :: Iso' PaymentCredential (PaymentCredential StandardCrypto)
_PaymentCredential = forall s a b t. (s -> a) -> (b -> t) -> Iso s t a b
iso PaymentCredential -> PaymentCredential StandardCrypto
from PaymentCredential StandardCrypto -> PaymentCredential
to where
  from :: C.PaymentCredential -> Credential.PaymentCredential StandardCrypto
  from :: PaymentCredential -> PaymentCredential StandardCrypto
from (C.PaymentCredentialByKey (C.PaymentKeyHash KeyHash 'Payment StandardCrypto
kh)) = forall {kr :: KeyRole} {c}. KeyHash kr c -> Credential kr c
Credential.KeyHashObj KeyHash 'Payment StandardCrypto
kh
  from (C.PaymentCredentialByScript ScriptHash
sh)                 = forall (kr :: KeyRole) c. ScriptHash c -> Credential kr c
Credential.ScriptHashObj (ScriptHash -> ScriptHash StandardCrypto
C.toShelleyScriptHash ScriptHash
sh)

  to :: PaymentCredential StandardCrypto -> PaymentCredential
to = PaymentCredential StandardCrypto -> PaymentCredential
C.fromShelleyPaymentCredential

_ScriptData :: forall a. (PV1.FromData a, PV1.ToData a) => Prism' C.ScriptData a
_ScriptData :: forall a. (FromData a, ToData a) => Prism' ScriptData a
_ScriptData = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' a -> ScriptData
from ScriptData -> Maybe a
to where
  to :: C.ScriptData -> Maybe a
  to :: ScriptData -> Maybe a
to = forall a. FromData a => ScriptData -> Maybe a
Scripts.fromScriptData

  from :: a -> C.ScriptData
  from :: a -> ScriptData
from = forall a. ToData a => a -> ScriptData
Scripts.toScriptData

_PlutusScriptWitnessV1 :: forall era witctx. Prism' (C.ScriptWitness witctx era) (C.ScriptLanguageInEra C.PlutusScriptV1 era, C.PlutusScriptVersion C.PlutusScriptV1, C.PlutusScriptOrReferenceInput C.PlutusScriptV1, C.ScriptDatum witctx, C.ScriptRedeemer, C.ExecutionUnits)
_PlutusScriptWitnessV1 :: forall era witctx.
Prism'
  (ScriptWitness witctx era)
  (ScriptLanguageInEra PlutusScriptV1 era,
   PlutusScriptVersion PlutusScriptV1,
   PlutusScriptOrReferenceInput PlutusScriptV1, ScriptDatum witctx,
   HashableScriptData, ExecutionUnits)
_PlutusScriptWitnessV1 = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (ScriptLanguageInEra PlutusScriptV1 era,
 PlutusScriptVersion PlutusScriptV1,
 PlutusScriptOrReferenceInput PlutusScriptV1, ScriptDatum witctx,
 HashableScriptData, ExecutionUnits)
-> ScriptWitness witctx era
from ScriptWitness witctx era
-> Maybe
     (ScriptLanguageInEra PlutusScriptV1 era,
      PlutusScriptVersion PlutusScriptV1,
      PlutusScriptOrReferenceInput PlutusScriptV1, ScriptDatum witctx,
      HashableScriptData, ExecutionUnits)
to where
  from :: (C.ScriptLanguageInEra C.PlutusScriptV1 era, C.PlutusScriptVersion C.PlutusScriptV1, C.PlutusScriptOrReferenceInput C.PlutusScriptV1, C.ScriptDatum witctx, C.ScriptRedeemer, C.ExecutionUnits) -> C.ScriptWitness witctx era
  from :: (ScriptLanguageInEra PlutusScriptV1 era,
 PlutusScriptVersion PlutusScriptV1,
 PlutusScriptOrReferenceInput PlutusScriptV1, ScriptDatum witctx,
 HashableScriptData, ExecutionUnits)
-> ScriptWitness witctx era
from (ScriptLanguageInEra PlutusScriptV1 era
lang, PlutusScriptVersion PlutusScriptV1
v, PlutusScriptOrReferenceInput PlutusScriptV1
i, ScriptDatum witctx
dtr, HashableScriptData
red, ExecutionUnits
ex) = forall lang era witctx.
ScriptLanguageInEra lang era
-> PlutusScriptVersion lang
-> PlutusScriptOrReferenceInput lang
-> ScriptDatum witctx
-> HashableScriptData
-> ExecutionUnits
-> ScriptWitness witctx era
C.PlutusScriptWitness ScriptLanguageInEra PlutusScriptV1 era
lang PlutusScriptVersion PlutusScriptV1
v PlutusScriptOrReferenceInput PlutusScriptV1
i ScriptDatum witctx
dtr HashableScriptData
red ExecutionUnits
ex

  to :: C.ScriptWitness witctx era -> Maybe (C.ScriptLanguageInEra C.PlutusScriptV1 era, C.PlutusScriptVersion C.PlutusScriptV1, C.PlutusScriptOrReferenceInput C.PlutusScriptV1, C.ScriptDatum witctx, C.ScriptRedeemer, C.ExecutionUnits)
  to :: ScriptWitness witctx era
-> Maybe
     (ScriptLanguageInEra PlutusScriptV1 era,
      PlutusScriptVersion PlutusScriptV1,
      PlutusScriptOrReferenceInput PlutusScriptV1, ScriptDatum witctx,
      HashableScriptData, ExecutionUnits)
to (C.PlutusScriptWitness ScriptLanguageInEra lang era
C.PlutusScriptV1InBabbage PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
i ScriptDatum witctx
dtr HashableScriptData
red ExecutionUnits
ex) = forall a. a -> Maybe a
Just (ScriptLanguageInEra PlutusScriptV1 BabbageEra
C.PlutusScriptV1InBabbage, PlutusScriptVersion lang
v, PlutusScriptOrReferenceInput lang
i, ScriptDatum witctx
dtr, HashableScriptData
red, ExecutionUnits
ex)
  to ScriptWitness witctx era
_ = forall a. Maybe a
Nothing

_PlutusScriptWitnessV2 :: forall era witctx. Prism' (C.ScriptWitness witctx era) (C.ScriptLanguageInEra C.PlutusScriptV2 era, C.PlutusScriptVersion C.PlutusScriptV2, C.PlutusScriptOrReferenceInput C.PlutusScriptV2, C.ScriptDatum witctx, C.ScriptRedeemer, C.ExecutionUnits)
_PlutusScriptWitnessV2 :: forall era witctx.
Prism'
  (ScriptWitness witctx era)
  (ScriptLanguageInEra PlutusScriptV2 era,
   PlutusScriptVersion PlutusScriptV2,
   PlutusScriptOrReferenceInput PlutusScriptV2, ScriptDatum witctx,
   HashableScriptData, ExecutionUnits)
_PlutusScriptWitnessV2 = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (ScriptLanguageInEra PlutusScriptV2 era,
 PlutusScriptVersion PlutusScriptV2,
 PlutusScriptOrReferenceInput PlutusScriptV2, ScriptDatum witctx,
 HashableScriptData, ExecutionUnits)
-> ScriptWitness witctx era
from ScriptWitness witctx era
-> Maybe
     (ScriptLanguageInEra PlutusScriptV2 era,
      PlutusScriptVersion PlutusScriptV2,
      PlutusScriptOrReferenceInput PlutusScriptV2, ScriptDatum witctx,
      HashableScriptData, ExecutionUnits)
to where
  from :: (C.ScriptLanguageInEra C.PlutusScriptV2 era, C.PlutusScriptVersion C.PlutusScriptV2, C.PlutusScriptOrReferenceInput C.PlutusScriptV2, C.ScriptDatum witctx, C.ScriptRedeemer, C.ExecutionUnits) -> C.ScriptWitness witctx era
  from :: (ScriptLanguageInEra PlutusScriptV2 era,
 PlutusScriptVersion PlutusScriptV2,
 PlutusScriptOrReferenceInput PlutusScriptV2, ScriptDatum witctx,
 HashableScriptData, ExecutionUnits)
-> ScriptWitness witctx era
from (ScriptLanguageInEra PlutusScriptV2 era
lang, PlutusScriptVersion PlutusScriptV2
v, PlutusScriptOrReferenceInput PlutusScriptV2
i, ScriptDatum witctx
dtr, HashableScriptData
red, ExecutionUnits
ex) = forall lang era witctx.
ScriptLanguageInEra lang era
-> PlutusScriptVersion lang
-> PlutusScriptOrReferenceInput lang
-> ScriptDatum witctx
-> HashableScriptData
-> ExecutionUnits
-> ScriptWitness witctx era
C.PlutusScriptWitness ScriptLanguageInEra PlutusScriptV2 era
lang PlutusScriptVersion PlutusScriptV2
v PlutusScriptOrReferenceInput PlutusScriptV2
i ScriptDatum witctx
dtr HashableScriptData
red ExecutionUnits
ex

  to :: C.ScriptWitness witctx era -> Maybe (C.ScriptLanguageInEra C.PlutusScriptV2 era, C.PlutusScriptVersion C.PlutusScriptV2, C.PlutusScriptOrReferenceInput C.PlutusScriptV2, C.ScriptDatum witctx, C.ScriptRedeemer, C.ExecutionUnits)
  to :: ScriptWitness witctx era
-> Maybe
     (ScriptLanguageInEra PlutusScriptV2 era,
      PlutusScriptVersion PlutusScriptV2,
      PlutusScriptOrReferenceInput PlutusScriptV2, ScriptDatum witctx,
      HashableScriptData, ExecutionUnits)
to (C.PlutusScriptWitness ScriptLanguageInEra lang era
C.PlutusScriptV2InBabbage PlutusScriptVersion lang
v PlutusScriptOrReferenceInput lang
i ScriptDatum witctx
dtr HashableScriptData
red ExecutionUnits
ex) = forall a. a -> Maybe a
Just (ScriptLanguageInEra PlutusScriptV2 BabbageEra
C.PlutusScriptV2InBabbage, PlutusScriptVersion lang
v, PlutusScriptOrReferenceInput lang
i, ScriptDatum witctx
dtr, HashableScriptData
red, ExecutionUnits
ex)
  to ScriptWitness witctx era
_ = forall a. Maybe a
Nothing

_TxValidityNoLowerBound :: forall era. Prism' (C.TxValidityLowerBound era) ()
_TxValidityNoLowerBound :: forall era. Prism' (TxValidityLowerBound era) ()
_TxValidityNoLowerBound = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {era}. () -> TxValidityLowerBound era
from forall {era}. TxValidityLowerBound era -> Maybe ()
to where
  from :: () -> TxValidityLowerBound era
from () = forall era. TxValidityLowerBound era
C.TxValidityNoLowerBound
  to :: TxValidityLowerBound era -> Maybe ()
to = \case
    TxValidityLowerBound era
C.TxValidityNoLowerBound -> forall a. a -> Maybe a
Just ()
    TxValidityLowerBound era
_                        -> forall a. Maybe a
Nothing

_TxValidityLowerBound :: forall era. Prism' (C.TxValidityLowerBound era) (C.ValidityLowerBoundSupportedInEra era, C.SlotNo)
_TxValidityLowerBound :: forall era.
Prism'
  (TxValidityLowerBound era)
  (ValidityLowerBoundSupportedInEra era, SlotNo)
_TxValidityLowerBound = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {era}.
(ValidityLowerBoundSupportedInEra era, SlotNo)
-> TxValidityLowerBound era
from forall {era}.
TxValidityLowerBound era
-> Maybe (ValidityLowerBoundSupportedInEra era, SlotNo)
to where
  from :: (ValidityLowerBoundSupportedInEra era, SlotNo)
-> TxValidityLowerBound era
from (ValidityLowerBoundSupportedInEra era
s, SlotNo
e) = forall era.
ValidityLowerBoundSupportedInEra era
-> SlotNo -> TxValidityLowerBound era
C.TxValidityLowerBound ValidityLowerBoundSupportedInEra era
s SlotNo
e
  to :: TxValidityLowerBound era
-> Maybe (ValidityLowerBoundSupportedInEra era, SlotNo)
to = \case
    C.TxValidityLowerBound ValidityLowerBoundSupportedInEra era
s SlotNo
e -> forall a. a -> Maybe a
Just (ValidityLowerBoundSupportedInEra era
s, SlotNo
e)
    TxValidityLowerBound era
_                          -> forall a. Maybe a
Nothing

_TxValidityNoUpperBound :: forall era. Prism' (C.TxValidityUpperBound era) (C.ValidityNoUpperBoundSupportedInEra era)
_TxValidityNoUpperBound :: forall era.
Prism'
  (TxValidityUpperBound era) (ValidityNoUpperBoundSupportedInEra era)
_TxValidityNoUpperBound = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall era.
ValidityNoUpperBoundSupportedInEra era -> TxValidityUpperBound era
from forall {era}.
TxValidityUpperBound era
-> Maybe (ValidityNoUpperBoundSupportedInEra era)
to where
  from :: ValidityNoUpperBoundSupportedInEra era -> TxValidityUpperBound era
from = forall era.
ValidityNoUpperBoundSupportedInEra era -> TxValidityUpperBound era
C.TxValidityNoUpperBound
  to :: TxValidityUpperBound era
-> Maybe (ValidityNoUpperBoundSupportedInEra era)
to = \case
    C.TxValidityNoUpperBound ValidityNoUpperBoundSupportedInEra era
k -> forall a. a -> Maybe a
Just ValidityNoUpperBoundSupportedInEra era
k
    TxValidityUpperBound era
_                          -> forall a. Maybe a
Nothing

_TxValidityUpperBound :: forall era. Prism' (C.TxValidityUpperBound era) (C.ValidityUpperBoundSupportedInEra era, SlotNo)
_TxValidityUpperBound :: forall era.
Prism'
  (TxValidityUpperBound era)
  (ValidityUpperBoundSupportedInEra era, SlotNo)
_TxValidityUpperBound = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' forall {era}.
(ValidityUpperBoundSupportedInEra era, SlotNo)
-> TxValidityUpperBound era
from forall {era}.
TxValidityUpperBound era
-> Maybe (ValidityUpperBoundSupportedInEra era, SlotNo)
to where
  from :: (ValidityUpperBoundSupportedInEra era, SlotNo)
-> TxValidityUpperBound era
from (ValidityUpperBoundSupportedInEra era
k, SlotNo
s) = forall era.
ValidityUpperBoundSupportedInEra era
-> SlotNo -> TxValidityUpperBound era
C.TxValidityUpperBound ValidityUpperBoundSupportedInEra era
k SlotNo
s
  to :: TxValidityUpperBound era
-> Maybe (ValidityUpperBoundSupportedInEra era, SlotNo)
to = \case
    C.TxValidityUpperBound ValidityUpperBoundSupportedInEra era
k SlotNo
s -> forall a. a -> Maybe a
Just (ValidityUpperBoundSupportedInEra era
k, SlotNo
s)
    TxValidityUpperBound era
_                          -> forall a. Maybe a
Nothing

_TxValidityFiniteRange :: Prism' (C.TxValidityLowerBound C.BabbageEra, C.TxValidityUpperBound C.BabbageEra) (SlotNo, SlotNo)
_TxValidityFiniteRange :: Prism'
  (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
  (SlotNo, SlotNo)
_TxValidityFiniteRange = forall b s a. (b -> s) -> (s -> Maybe a) -> Prism s s a b
prism' (SlotNo, SlotNo)
-> (TxValidityLowerBound BabbageEra,
    TxValidityUpperBound BabbageEra)
from forall {era} {era}.
(TxValidityLowerBound era, TxValidityUpperBound era)
-> Maybe (SlotNo, SlotNo)
to where
  from :: (SlotNo, SlotNo)
-> (TxValidityLowerBound BabbageEra,
    TxValidityUpperBound BabbageEra)
from (SlotNo
l, SlotNo
u) = (forall era.
ValidityLowerBoundSupportedInEra era
-> SlotNo -> TxValidityLowerBound era
C.TxValidityLowerBound ValidityLowerBoundSupportedInEra BabbageEra
C.ValidityLowerBoundInBabbageEra SlotNo
l, forall era.
ValidityUpperBoundSupportedInEra era
-> SlotNo -> TxValidityUpperBound era
C.TxValidityUpperBound ValidityUpperBoundSupportedInEra BabbageEra
C.ValidityUpperBoundInBabbageEra SlotNo
u)
  to :: (TxValidityLowerBound era, TxValidityUpperBound era)
-> Maybe (SlotNo, SlotNo)
to = \case
    (C.TxValidityLowerBound ValidityLowerBoundSupportedInEra era
_ SlotNo
l, C.TxValidityUpperBound ValidityUpperBoundSupportedInEra era
_ SlotNo
u) -> forall a. a -> Maybe a
Just (SlotNo
l, SlotNo
u)
    (TxValidityLowerBound era, TxValidityUpperBound era)
_                                                        -> forall a. Maybe a
Nothing