{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -Wno-redundant-constraints #-}
module Ledger.Tx
( module Export
, C.TxId(..)
, C.TxIn(..)
, C.TxIx(..)
, DecoratedTxOut(..)
, toTxOut
, toTxInfoTxOut
, toDecoratedTxOut
, decoratedTxOutPubKeyHash
, decoratedTxOutAddress
, decoratedTxOutDatum
, decoratedTxOutValue
, decoratedTxOutPubKeyDatum
, decoratedTxOutScriptDatum
, decoratedTxOutStakingCredential
, decoratedTxOutReferenceScript
, decoratedTxOutValidatorHash
, decoratedTxOutValidator
, _PublicKeyDecoratedTxOut
, _ScriptDecoratedTxOut
, _decoratedTxOutAddress
, mkDecoratedTxOut
, mkPubkeyDecoratedTxOut
, mkScriptDecoratedTxOut
, DatumFromQuery(..)
, datumInDatumFromQuery
, getCardanoTxId
, getCardanoTxInputs
, getCardanoTxCollateralInputs
, getCardanoTxOutRefs
, getCardanoTxOutputs
, getCardanoTxRedeemers
, getCardanoTxSpentOutputs
, getCardanoTxProducedOutputs
, getCardanoTxReturnCollateral
, getCardanoTxProducedReturnCollateral
, getCardanoTxTotalCollateral
, getCardanoTxFee
, getCardanoTxMint
, getCardanoTxValidityRange
, getCardanoTxData
, CardanoTx(.., CardanoEmulatorEraTx)
, ToCardanoError(..)
, addCardanoTxSignature
, getTxBodyContentInputs
, getTxBodyContentCollateralInputs
, getTxBodyContentReturnCollateral
, getTxBodyContentMint
, txBodyContentIns
, txBodyContentCollateralIns
, txBodyContentOuts
, decoratedTxOutPlutusValue
, fromDecoratedIndex
) where
import Cardano.Api qualified as C
import Cardano.Api.Shelley qualified as C.Api
import Cardano.Crypto.Wallet qualified as Crypto
import Cardano.Ledger.Alonzo.Tx (ValidatedTx (..))
import Cardano.Ledger.Alonzo.TxWitness (txwitsVKey)
import Codec.Serialise (Serialise)
import Control.Lens (Getter, Lens', Traversal', lens, makeLenses, makePrisms, to, view, views, (^.), (^?))
import Data.Aeson (FromJSON, ToJSON)
import Data.Coerce (coerce)
import Data.Map (Map)
import Data.Map qualified as Map
import Data.Set (Set)
import Data.Set qualified as Set
import Data.Tuple (swap)
import GHC.Generics (Generic)
import Ledger.Address (Address, CardanoAddress, cardanoAddressCredential, cardanoStakingCredential)
import Ledger.Orphans ()
import Ledger.Slot (SlotRange)
import Ledger.Tx.CardanoAPI (CardanoTx (CardanoTx), ToCardanoError (..), pattern CardanoEmulatorEraTx)
import Ledger.Tx.CardanoAPI qualified as CardanoAPI
import Plutus.Script.Utils.Scripts (scriptHash)
import Plutus.V1.Ledger.Api qualified as V1
import Plutus.V2.Ledger.Api qualified as V2
import Plutus.V2.Ledger.Tx qualified as V2.Tx hiding (TxId (..), TxIn (..), TxInType (..))
import Prettyprinter (Pretty (pretty), colon, hang, nest, viaShow, vsep, (<+>))
import Ledger.Index.Internal (UtxoIndex)
import Ledger.Tx.Internal as Export
import Plutus.V1.Ledger.Tx as Export hiding (TxId (..), TxIn (..), TxInType (..), TxOut (..), inRef, inType, outAddress,
outValue, pubKeyTxIn, scriptTxIn, txOutDatum, txOutPubKey)
import Plutus.V1.Ledger.Value (Value)
data DatumFromQuery
= DatumUnknown
| DatumInline V2.Datum
| DatumInBody V2.Datum
deriving (Int -> DatumFromQuery -> ShowS
[DatumFromQuery] -> ShowS
DatumFromQuery -> String
(Int -> DatumFromQuery -> ShowS)
-> (DatumFromQuery -> String)
-> ([DatumFromQuery] -> ShowS)
-> Show DatumFromQuery
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DatumFromQuery] -> ShowS
$cshowList :: [DatumFromQuery] -> ShowS
show :: DatumFromQuery -> String
$cshow :: DatumFromQuery -> String
showsPrec :: Int -> DatumFromQuery -> ShowS
$cshowsPrec :: Int -> DatumFromQuery -> ShowS
Show, DatumFromQuery -> DatumFromQuery -> Bool
(DatumFromQuery -> DatumFromQuery -> Bool)
-> (DatumFromQuery -> DatumFromQuery -> Bool) -> Eq DatumFromQuery
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DatumFromQuery -> DatumFromQuery -> Bool
$c/= :: DatumFromQuery -> DatumFromQuery -> Bool
== :: DatumFromQuery -> DatumFromQuery -> Bool
$c== :: DatumFromQuery -> DatumFromQuery -> Bool
Eq, [DatumFromQuery] -> Encoding
DatumFromQuery -> Encoding
(DatumFromQuery -> Encoding)
-> (forall s. Decoder s DatumFromQuery)
-> ([DatumFromQuery] -> Encoding)
-> (forall s. Decoder s [DatumFromQuery])
-> Serialise DatumFromQuery
forall s. Decoder s [DatumFromQuery]
forall s. Decoder s DatumFromQuery
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [DatumFromQuery]
$cdecodeList :: forall s. Decoder s [DatumFromQuery]
encodeList :: [DatumFromQuery] -> Encoding
$cencodeList :: [DatumFromQuery] -> Encoding
decode :: Decoder s DatumFromQuery
$cdecode :: forall s. Decoder s DatumFromQuery
encode :: DatumFromQuery -> Encoding
$cencode :: DatumFromQuery -> Encoding
Serialise, (forall x. DatumFromQuery -> Rep DatumFromQuery x)
-> (forall x. Rep DatumFromQuery x -> DatumFromQuery)
-> Generic DatumFromQuery
forall x. Rep DatumFromQuery x -> DatumFromQuery
forall x. DatumFromQuery -> Rep DatumFromQuery x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DatumFromQuery x -> DatumFromQuery
$cfrom :: forall x. DatumFromQuery -> Rep DatumFromQuery x
Generic, [DatumFromQuery] -> Encoding
[DatumFromQuery] -> Value
DatumFromQuery -> Encoding
DatumFromQuery -> Value
(DatumFromQuery -> Value)
-> (DatumFromQuery -> Encoding)
-> ([DatumFromQuery] -> Value)
-> ([DatumFromQuery] -> Encoding)
-> ToJSON DatumFromQuery
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [DatumFromQuery] -> Encoding
$ctoEncodingList :: [DatumFromQuery] -> Encoding
toJSONList :: [DatumFromQuery] -> Value
$ctoJSONList :: [DatumFromQuery] -> Value
toEncoding :: DatumFromQuery -> Encoding
$ctoEncoding :: DatumFromQuery -> Encoding
toJSON :: DatumFromQuery -> Value
$ctoJSON :: DatumFromQuery -> Value
ToJSON, Value -> Parser [DatumFromQuery]
Value -> Parser DatumFromQuery
(Value -> Parser DatumFromQuery)
-> (Value -> Parser [DatumFromQuery]) -> FromJSON DatumFromQuery
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DatumFromQuery]
$cparseJSONList :: Value -> Parser [DatumFromQuery]
parseJSON :: Value -> Parser DatumFromQuery
$cparseJSON :: Value -> Parser DatumFromQuery
FromJSON)
makePrisms ''DatumFromQuery
datumInDatumFromQuery :: Traversal' DatumFromQuery V2.Datum
datumInDatumFromQuery :: (Datum -> f Datum) -> DatumFromQuery -> f DatumFromQuery
datumInDatumFromQuery Datum -> f Datum
_ DatumFromQuery
DatumUnknown = DatumFromQuery -> f DatumFromQuery
forall (f :: * -> *) a. Applicative f => a -> f a
pure DatumFromQuery
DatumUnknown
datumInDatumFromQuery Datum -> f Datum
f (DatumInline Datum
d) = Datum -> DatumFromQuery
DatumInline (Datum -> DatumFromQuery) -> f Datum -> f DatumFromQuery
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Datum -> f Datum
f Datum
d
datumInDatumFromQuery Datum -> f Datum
f (DatumInBody Datum
d) = Datum -> DatumFromQuery
DatumInBody (Datum -> DatumFromQuery) -> f Datum -> f DatumFromQuery
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Datum -> f Datum
f Datum
d
data DecoratedTxOut =
PublicKeyDecoratedTxOut {
DecoratedTxOut -> PubKeyHash
_decoratedTxOutPubKeyHash :: V1.PubKeyHash,
DecoratedTxOut -> Maybe StakingCredential
_decoratedTxOutStakingCredential :: Maybe V1.StakingCredential,
DecoratedTxOut -> Value
_decoratedTxOutValue :: C.Value,
DecoratedTxOut -> Maybe (DatumHash, DatumFromQuery)
_decoratedTxOutPubKeyDatum :: Maybe (V2.DatumHash, DatumFromQuery),
DecoratedTxOut -> Maybe (Versioned Script)
_decoratedTxOutReferenceScript :: Maybe (Versioned V1.Script)
}
| ScriptDecoratedTxOut {
DecoratedTxOut -> ValidatorHash
_decoratedTxOutValidatorHash :: V1.ValidatorHash,
_decoratedTxOutStakingCredential :: Maybe V1.StakingCredential,
_decoratedTxOutValue :: C.Value,
DecoratedTxOut -> (DatumHash, DatumFromQuery)
_decoratedTxOutScriptDatum :: (V2.DatumHash, DatumFromQuery),
_decoratedTxOutReferenceScript :: Maybe (Versioned V1.Script),
DecoratedTxOut -> Maybe (Versioned Validator)
_decoratedTxOutValidator :: Maybe (Versioned V1.Validator)
}
deriving (Int -> DecoratedTxOut -> ShowS
[DecoratedTxOut] -> ShowS
DecoratedTxOut -> String
(Int -> DecoratedTxOut -> ShowS)
-> (DecoratedTxOut -> String)
-> ([DecoratedTxOut] -> ShowS)
-> Show DecoratedTxOut
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DecoratedTxOut] -> ShowS
$cshowList :: [DecoratedTxOut] -> ShowS
show :: DecoratedTxOut -> String
$cshow :: DecoratedTxOut -> String
showsPrec :: Int -> DecoratedTxOut -> ShowS
$cshowsPrec :: Int -> DecoratedTxOut -> ShowS
Show, DecoratedTxOut -> DecoratedTxOut -> Bool
(DecoratedTxOut -> DecoratedTxOut -> Bool)
-> (DecoratedTxOut -> DecoratedTxOut -> Bool) -> Eq DecoratedTxOut
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DecoratedTxOut -> DecoratedTxOut -> Bool
$c/= :: DecoratedTxOut -> DecoratedTxOut -> Bool
== :: DecoratedTxOut -> DecoratedTxOut -> Bool
$c== :: DecoratedTxOut -> DecoratedTxOut -> Bool
Eq, [DecoratedTxOut] -> Encoding
DecoratedTxOut -> Encoding
(DecoratedTxOut -> Encoding)
-> (forall s. Decoder s DecoratedTxOut)
-> ([DecoratedTxOut] -> Encoding)
-> (forall s. Decoder s [DecoratedTxOut])
-> Serialise DecoratedTxOut
forall s. Decoder s [DecoratedTxOut]
forall s. Decoder s DecoratedTxOut
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
decodeList :: Decoder s [DecoratedTxOut]
$cdecodeList :: forall s. Decoder s [DecoratedTxOut]
encodeList :: [DecoratedTxOut] -> Encoding
$cencodeList :: [DecoratedTxOut] -> Encoding
decode :: Decoder s DecoratedTxOut
$cdecode :: forall s. Decoder s DecoratedTxOut
encode :: DecoratedTxOut -> Encoding
$cencode :: DecoratedTxOut -> Encoding
Serialise, (forall x. DecoratedTxOut -> Rep DecoratedTxOut x)
-> (forall x. Rep DecoratedTxOut x -> DecoratedTxOut)
-> Generic DecoratedTxOut
forall x. Rep DecoratedTxOut x -> DecoratedTxOut
forall x. DecoratedTxOut -> Rep DecoratedTxOut x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DecoratedTxOut x -> DecoratedTxOut
$cfrom :: forall x. DecoratedTxOut -> Rep DecoratedTxOut x
Generic, [DecoratedTxOut] -> Encoding
[DecoratedTxOut] -> Value
DecoratedTxOut -> Encoding
DecoratedTxOut -> Value
(DecoratedTxOut -> Value)
-> (DecoratedTxOut -> Encoding)
-> ([DecoratedTxOut] -> Value)
-> ([DecoratedTxOut] -> Encoding)
-> ToJSON DecoratedTxOut
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [DecoratedTxOut] -> Encoding
$ctoEncodingList :: [DecoratedTxOut] -> Encoding
toJSONList :: [DecoratedTxOut] -> Value
$ctoJSONList :: [DecoratedTxOut] -> Value
toEncoding :: DecoratedTxOut -> Encoding
$ctoEncoding :: DecoratedTxOut -> Encoding
toJSON :: DecoratedTxOut -> Value
$ctoJSON :: DecoratedTxOut -> Value
ToJSON, Value -> Parser [DecoratedTxOut]
Value -> Parser DecoratedTxOut
(Value -> Parser DecoratedTxOut)
-> (Value -> Parser [DecoratedTxOut]) -> FromJSON DecoratedTxOut
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [DecoratedTxOut]
$cparseJSONList :: Value -> Parser [DecoratedTxOut]
parseJSON :: Value -> Parser DecoratedTxOut
$cparseJSON :: Value -> Parser DecoratedTxOut
FromJSON)
makeLenses ''DecoratedTxOut
makePrisms ''DecoratedTxOut
mkDecoratedTxOut
:: CardanoAddress -> C.Value -> Maybe (V2.DatumHash, DatumFromQuery) -> Maybe (Versioned V1.Script)
-> Maybe DecoratedTxOut
mkDecoratedTxOut :: CardanoAddress
-> Value
-> Maybe (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe DecoratedTxOut
mkDecoratedTxOut CardanoAddress
a Value
v Maybe (DatumHash, DatumFromQuery)
md Maybe (Versioned Script)
rs = let
sc :: Maybe StakingCredential
sc = CardanoAddress -> Maybe StakingCredential
forall era. AddressInEra era -> Maybe StakingCredential
cardanoStakingCredential CardanoAddress
a
in case CardanoAddress -> Credential
forall era. AddressInEra era -> Credential
cardanoAddressCredential CardanoAddress
a of
(V2.PubKeyCredential PubKeyHash
c) -> DecoratedTxOut -> Maybe DecoratedTxOut
forall a. a -> Maybe a
Just (PubKeyHash
-> Maybe StakingCredential
-> Value
-> Maybe (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> DecoratedTxOut
PublicKeyDecoratedTxOut PubKeyHash
c Maybe StakingCredential
sc Value
v Maybe (DatumHash, DatumFromQuery)
md Maybe (Versioned Script)
rs)
(V2.ScriptCredential ValidatorHash
c) -> (\(DatumHash, DatumFromQuery)
dt -> ValidatorHash
-> Maybe StakingCredential
-> Value
-> (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe (Versioned Validator)
-> DecoratedTxOut
ScriptDecoratedTxOut ValidatorHash
c Maybe StakingCredential
sc Value
v (DatumHash, DatumFromQuery)
dt Maybe (Versioned Script)
rs Maybe (Versioned Validator)
forall a. Maybe a
Nothing) ((DatumHash, DatumFromQuery) -> DecoratedTxOut)
-> Maybe (DatumHash, DatumFromQuery) -> Maybe DecoratedTxOut
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (DatumHash, DatumFromQuery)
md
mkPubkeyDecoratedTxOut
:: CardanoAddress -> C.Value -> Maybe (V2.DatumHash, DatumFromQuery) -> Maybe (Versioned V1.Script)
-> Maybe DecoratedTxOut
mkPubkeyDecoratedTxOut :: CardanoAddress
-> Value
-> Maybe (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe DecoratedTxOut
mkPubkeyDecoratedTxOut CardanoAddress
a Value
v Maybe (DatumHash, DatumFromQuery)
dat Maybe (Versioned Script)
rs = let
sc :: Maybe StakingCredential
sc = CardanoAddress -> Maybe StakingCredential
forall era. AddressInEra era -> Maybe StakingCredential
cardanoStakingCredential CardanoAddress
a
in case CardanoAddress -> Credential
forall era. AddressInEra era -> Credential
cardanoAddressCredential CardanoAddress
a of
(V2.PubKeyCredential PubKeyHash
c) -> DecoratedTxOut -> Maybe DecoratedTxOut
forall a. a -> Maybe a
Just (DecoratedTxOut -> Maybe DecoratedTxOut)
-> DecoratedTxOut -> Maybe DecoratedTxOut
forall a b. (a -> b) -> a -> b
$ PubKeyHash
-> Maybe StakingCredential
-> Value
-> Maybe (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> DecoratedTxOut
PublicKeyDecoratedTxOut PubKeyHash
c Maybe StakingCredential
sc Value
v Maybe (DatumHash, DatumFromQuery)
dat Maybe (Versioned Script)
rs
Credential
_ -> Maybe DecoratedTxOut
forall a. Maybe a
Nothing
mkScriptDecoratedTxOut
:: CardanoAddress
-> C.Value
-> (V2.DatumHash, DatumFromQuery)
-> Maybe (Versioned V1.Script)
-> Maybe (Versioned V1.Validator)
-> Maybe DecoratedTxOut
mkScriptDecoratedTxOut :: CardanoAddress
-> Value
-> (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe (Versioned Validator)
-> Maybe DecoratedTxOut
mkScriptDecoratedTxOut CardanoAddress
a Value
v (DatumHash, DatumFromQuery)
dat Maybe (Versioned Script)
rs Maybe (Versioned Validator)
val = let
sc :: Maybe StakingCredential
sc = CardanoAddress -> Maybe StakingCredential
forall era. AddressInEra era -> Maybe StakingCredential
cardanoStakingCredential CardanoAddress
a
in case CardanoAddress -> Credential
forall era. AddressInEra era -> Credential
cardanoAddressCredential CardanoAddress
a of
(V2.ScriptCredential ValidatorHash
c) -> DecoratedTxOut -> Maybe DecoratedTxOut
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DecoratedTxOut -> Maybe DecoratedTxOut)
-> DecoratedTxOut -> Maybe DecoratedTxOut
forall a b. (a -> b) -> a -> b
$ ValidatorHash
-> Maybe StakingCredential
-> Value
-> (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe (Versioned Validator)
-> DecoratedTxOut
ScriptDecoratedTxOut ValidatorHash
c Maybe StakingCredential
sc Value
v (DatumHash, DatumFromQuery)
dat Maybe (Versioned Script)
rs Maybe (Versioned Validator)
val
Credential
_ -> Maybe DecoratedTxOut
forall a. Maybe a
Nothing
_decoratedTxOutAddress :: DecoratedTxOut -> Address
_decoratedTxOutAddress :: DecoratedTxOut -> Address
_decoratedTxOutAddress PublicKeyDecoratedTxOut{PubKeyHash
_decoratedTxOutPubKeyHash :: PubKeyHash
_decoratedTxOutPubKeyHash :: DecoratedTxOut -> PubKeyHash
_decoratedTxOutPubKeyHash, Maybe StakingCredential
_decoratedTxOutStakingCredential :: Maybe StakingCredential
_decoratedTxOutStakingCredential :: DecoratedTxOut -> Maybe StakingCredential
_decoratedTxOutStakingCredential} =
Credential -> Maybe StakingCredential -> Address
V1.Address (PubKeyHash -> Credential
V1.PubKeyCredential PubKeyHash
_decoratedTxOutPubKeyHash) Maybe StakingCredential
_decoratedTxOutStakingCredential
_decoratedTxOutAddress ScriptDecoratedTxOut{ValidatorHash
_decoratedTxOutValidatorHash :: ValidatorHash
_decoratedTxOutValidatorHash :: DecoratedTxOut -> ValidatorHash
_decoratedTxOutValidatorHash, Maybe StakingCredential
_decoratedTxOutStakingCredential :: Maybe StakingCredential
_decoratedTxOutStakingCredential :: DecoratedTxOut -> Maybe StakingCredential
_decoratedTxOutStakingCredential} =
Credential -> Maybe StakingCredential -> Address
V1.Address (ValidatorHash -> Credential
V1.ScriptCredential ValidatorHash
_decoratedTxOutValidatorHash) Maybe StakingCredential
_decoratedTxOutStakingCredential
decoratedTxOutAddress :: Getter DecoratedTxOut Address
decoratedTxOutAddress :: (Address -> f Address) -> DecoratedTxOut -> f DecoratedTxOut
decoratedTxOutAddress = (DecoratedTxOut -> Address)
-> (Address -> f Address) -> DecoratedTxOut -> f DecoratedTxOut
forall (p :: * -> * -> *) (f :: * -> *) s a.
(Profunctor p, Contravariant f) =>
(s -> a) -> Optic' p f s a
to DecoratedTxOut -> Address
_decoratedTxOutAddress
decoratedTxOutDatum :: Traversal' DecoratedTxOut (V2.DatumHash, DatumFromQuery)
decoratedTxOutDatum :: ((DatumHash, DatumFromQuery) -> f (DatumHash, DatumFromQuery))
-> DecoratedTxOut -> f DecoratedTxOut
decoratedTxOutDatum (DatumHash, DatumFromQuery) -> f (DatumHash, DatumFromQuery)
f p :: DecoratedTxOut
p@(PublicKeyDecoratedTxOut PubKeyHash
pkh Maybe StakingCredential
sc Value
v Maybe (DatumHash, DatumFromQuery)
dat Maybe (Versioned Script)
rs) =
f DecoratedTxOut
-> ((DatumHash, DatumFromQuery) -> f DecoratedTxOut)
-> Maybe (DatumHash, DatumFromQuery)
-> f DecoratedTxOut
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (DecoratedTxOut -> f DecoratedTxOut
forall (f :: * -> *) a. Applicative f => a -> f a
pure DecoratedTxOut
p) (((DatumHash, DatumFromQuery) -> DecoratedTxOut)
-> f (DatumHash, DatumFromQuery) -> f DecoratedTxOut
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\ (DatumHash, DatumFromQuery)
dat' -> PubKeyHash
-> Maybe StakingCredential
-> Value
-> Maybe (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> DecoratedTxOut
PublicKeyDecoratedTxOut PubKeyHash
pkh Maybe StakingCredential
sc Value
v ((DatumHash, DatumFromQuery) -> Maybe (DatumHash, DatumFromQuery)
forall a. a -> Maybe a
Just (DatumHash, DatumFromQuery)
dat') Maybe (Versioned Script)
rs) (f (DatumHash, DatumFromQuery) -> f DecoratedTxOut)
-> ((DatumHash, DatumFromQuery) -> f (DatumHash, DatumFromQuery))
-> (DatumHash, DatumFromQuery)
-> f DecoratedTxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (DatumHash, DatumFromQuery) -> f (DatumHash, DatumFromQuery)
f) Maybe (DatumHash, DatumFromQuery)
dat
decoratedTxOutDatum (DatumHash, DatumFromQuery) -> f (DatumHash, DatumFromQuery)
f (ScriptDecoratedTxOut ValidatorHash
vh Maybe StakingCredential
sc Value
v (DatumHash, DatumFromQuery)
dat Maybe (Versioned Script)
rs Maybe (Versioned Validator)
val) =
(\(DatumHash, DatumFromQuery)
dat' -> ValidatorHash
-> Maybe StakingCredential
-> Value
-> (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe (Versioned Validator)
-> DecoratedTxOut
ScriptDecoratedTxOut ValidatorHash
vh Maybe StakingCredential
sc Value
v (DatumHash, DatumFromQuery)
dat' Maybe (Versioned Script)
rs Maybe (Versioned Validator)
val) ((DatumHash, DatumFromQuery) -> DecoratedTxOut)
-> f (DatumHash, DatumFromQuery) -> f DecoratedTxOut
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (DatumHash, DatumFromQuery) -> f (DatumHash, DatumFromQuery)
f (DatumHash, DatumFromQuery)
dat
toDecoratedTxOut :: TxOut -> Maybe DecoratedTxOut
toDecoratedTxOut :: TxOut -> Maybe DecoratedTxOut
toDecoratedTxOut (TxOut (C.TxOut CardanoAddress
addr' TxOutValue BabbageEra
val TxOutDatum CtxTx BabbageEra
dt ReferenceScript BabbageEra
rs)) =
CardanoAddress
-> Value
-> Maybe (DatumHash, DatumFromQuery)
-> Maybe (Versioned Script)
-> Maybe DecoratedTxOut
mkDecoratedTxOut CardanoAddress
addr' (TxOutValue BabbageEra -> Value
forall era. TxOutValue era -> Value
C.txOutValueToValue TxOutValue BabbageEra
val) (TxOutDatum CtxTx BabbageEra -> Maybe (DatumHash, DatumFromQuery)
toDecoratedDatum TxOutDatum CtxTx BabbageEra
dt) (ReferenceScript BabbageEra -> Maybe (Versioned Script)
CardanoAPI.fromCardanoReferenceScript ReferenceScript BabbageEra
rs)
where
toDecoratedDatum :: C.TxOutDatum C.CtxTx C.BabbageEra -> Maybe (V2.DatumHash, DatumFromQuery)
toDecoratedDatum :: TxOutDatum CtxTx BabbageEra -> Maybe (DatumHash, DatumFromQuery)
toDecoratedDatum TxOutDatum CtxTx BabbageEra
C.TxOutDatumNone =
Maybe (DatumHash, DatumFromQuery)
forall a. Maybe a
Nothing
toDecoratedDatum (C.TxOutDatumHash ScriptDataSupportedInEra BabbageEra
_ Hash ScriptData
h) =
(DatumHash, DatumFromQuery) -> Maybe (DatumHash, DatumFromQuery)
forall a. a -> Maybe a
Just (BuiltinByteString -> DatumHash
V2.DatumHash (BuiltinByteString -> DatumHash) -> BuiltinByteString -> DatumHash
forall a b. (a -> b) -> a -> b
$ ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
V2.toBuiltin (Hash ScriptData -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
C.serialiseToRawBytes Hash ScriptData
h), DatumFromQuery
DatumUnknown)
toDecoratedDatum (C.TxOutDatumInTx ScriptDataSupportedInEra BabbageEra
_ ScriptData
d) =
(DatumHash, DatumFromQuery) -> Maybe (DatumHash, DatumFromQuery)
forall a. a -> Maybe a
Just (BuiltinByteString -> DatumHash
V2.DatumHash (BuiltinByteString -> DatumHash) -> BuiltinByteString -> DatumHash
forall a b. (a -> b) -> a -> b
$ ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
V2.toBuiltin (Hash ScriptData -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
C.serialiseToRawBytes (ScriptData -> Hash ScriptData
C.hashScriptData ScriptData
d)), Datum -> DatumFromQuery
DatumInBody (Datum -> DatumFromQuery) -> Datum -> DatumFromQuery
forall a b. (a -> b) -> a -> b
$ BuiltinData -> Datum
V2.Datum (BuiltinData -> Datum) -> BuiltinData -> Datum
forall a b. (a -> b) -> a -> b
$ ScriptData -> BuiltinData
CardanoAPI.fromCardanoScriptData ScriptData
d)
toDecoratedDatum (C.TxOutDatumInline ReferenceTxInsScriptsInlineDatumsSupportedInEra BabbageEra
_ ScriptData
d) =
(DatumHash, DatumFromQuery) -> Maybe (DatumHash, DatumFromQuery)
forall a. a -> Maybe a
Just (BuiltinByteString -> DatumHash
V2.DatumHash (BuiltinByteString -> DatumHash) -> BuiltinByteString -> DatumHash
forall a b. (a -> b) -> a -> b
$ ByteString -> BuiltinByteString
forall a arep. ToBuiltin a arep => a -> arep
V2.toBuiltin (Hash ScriptData -> ByteString
forall a. SerialiseAsRawBytes a => a -> ByteString
C.serialiseToRawBytes (ScriptData -> Hash ScriptData
C.hashScriptData ScriptData
d)), Datum -> DatumFromQuery
DatumInline (Datum -> DatumFromQuery) -> Datum -> DatumFromQuery
forall a b. (a -> b) -> a -> b
$ BuiltinData -> Datum
V2.Datum (BuiltinData -> Datum) -> BuiltinData -> Datum
forall a b. (a -> b) -> a -> b
$ ScriptData -> BuiltinData
CardanoAPI.fromCardanoScriptData ScriptData
d)
toTxOut :: C.NetworkId -> DecoratedTxOut -> Either ToCardanoError TxOut
toTxOut :: NetworkId -> DecoratedTxOut -> Either ToCardanoError TxOut
toTxOut NetworkId
networkId DecoratedTxOut
p =
TxOut CtxTx BabbageEra -> TxOut
TxOut (TxOut CtxTx BabbageEra -> TxOut)
-> Either ToCardanoError (TxOut CtxTx BabbageEra)
-> Either ToCardanoError TxOut
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (CardanoAddress
-> TxOutValue BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxTx BabbageEra
forall ctx era.
AddressInEra era
-> TxOutValue era
-> TxOutDatum ctx era
-> ReferenceScript era
-> TxOut ctx era
C.TxOut
(CardanoAddress
-> TxOutValue BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxTx BabbageEra)
-> Either ToCardanoError CardanoAddress
-> Either
ToCardanoError
(TxOutValue BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxTx BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NetworkId -> Address -> Either ToCardanoError CardanoAddress
CardanoAPI.toCardanoAddressInEra NetworkId
networkId (DecoratedTxOut
p DecoratedTxOut -> Getting Address DecoratedTxOut Address -> Address
forall s a. s -> Getting a s a -> a
^. Getting Address DecoratedTxOut Address
Getter DecoratedTxOut Address
decoratedTxOutAddress)
Either
ToCardanoError
(TxOutValue BabbageEra
-> TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra
-> TxOut CtxTx BabbageEra)
-> Either ToCardanoError (TxOutValue BabbageEra)
-> Either
ToCardanoError
(TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra -> TxOut CtxTx BabbageEra)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> TxOutValue BabbageEra
-> Either ToCardanoError (TxOutValue BabbageEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Value -> TxOutValue BabbageEra
CardanoAPI.toCardanoTxOutValue (DecoratedTxOut
p DecoratedTxOut -> Getting Value DecoratedTxOut Value -> Value
forall s a. s -> Getting a s a -> a
^. Getting Value DecoratedTxOut Value
Lens' DecoratedTxOut Value
decoratedTxOutValue))
Either
ToCardanoError
(TxOutDatum CtxTx BabbageEra
-> ReferenceScript BabbageEra -> TxOut CtxTx BabbageEra)
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra)
-> Either
ToCardanoError
(ReferenceScript BabbageEra -> TxOut CtxTx BabbageEra)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> (Maybe (DatumHash, DatumFromQuery)
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra)
toTxOutDatum (Maybe (DatumHash, DatumFromQuery)
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra))
-> Maybe (DatumHash, DatumFromQuery)
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra)
forall a b. (a -> b) -> a -> b
$ DecoratedTxOut
p DecoratedTxOut
-> Getting
(First (DatumHash, DatumFromQuery))
DecoratedTxOut
(DatumHash, DatumFromQuery)
-> Maybe (DatumHash, DatumFromQuery)
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting
(First (DatumHash, DatumFromQuery))
DecoratedTxOut
(DatumHash, DatumFromQuery)
Traversal' DecoratedTxOut (DatumHash, DatumFromQuery)
decoratedTxOutDatum)
Either
ToCardanoError
(ReferenceScript BabbageEra -> TxOut CtxTx BabbageEra)
-> Either ToCardanoError (ReferenceScript BabbageEra)
-> Either ToCardanoError (TxOut CtxTx BabbageEra)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe (Versioned Script)
-> Either ToCardanoError (ReferenceScript BabbageEra)
CardanoAPI.toCardanoReferenceScript (DecoratedTxOut
p DecoratedTxOut
-> Getting
(Maybe (Versioned Script))
DecoratedTxOut
(Maybe (Versioned Script))
-> Maybe (Versioned Script)
forall s a. s -> Getting a s a -> a
^. Getting
(Maybe (Versioned Script))
DecoratedTxOut
(Maybe (Versioned Script))
Lens' DecoratedTxOut (Maybe (Versioned Script))
decoratedTxOutReferenceScript))
toTxOutDatum :: Maybe (V2.DatumHash, DatumFromQuery) -> Either ToCardanoError (C.TxOutDatum C.CtxTx C.BabbageEra)
toTxOutDatum :: Maybe (DatumHash, DatumFromQuery)
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra)
toTxOutDatum = OutputDatum -> Either ToCardanoError (TxOutDatum CtxTx BabbageEra)
CardanoAPI.toCardanoTxOutDatum (OutputDatum
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra))
-> (Maybe (DatumHash, DatumFromQuery) -> OutputDatum)
-> Maybe (DatumHash, DatumFromQuery)
-> Either ToCardanoError (TxOutDatum CtxTx BabbageEra)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (DatumHash, DatumFromQuery) -> OutputDatum
toPlutusOutputDatum
toTxInfoTxOut :: DecoratedTxOut -> V2.Tx.TxOut
toTxInfoTxOut :: DecoratedTxOut -> TxOut
toTxInfoTxOut DecoratedTxOut
p =
Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
V2.Tx.TxOut (DecoratedTxOut
p DecoratedTxOut -> Getting Address DecoratedTxOut Address -> Address
forall s a. s -> Getting a s a -> a
^. Getting Address DecoratedTxOut Address
Getter DecoratedTxOut Address
decoratedTxOutAddress) (Value -> Value
CardanoAPI.fromCardanoValue (Value -> Value) -> Value -> Value
forall a b. (a -> b) -> a -> b
$ DecoratedTxOut
p DecoratedTxOut -> Getting Value DecoratedTxOut Value -> Value
forall s a. s -> Getting a s a -> a
^. Getting Value DecoratedTxOut Value
Lens' DecoratedTxOut Value
decoratedTxOutValue)
(Maybe (DatumHash, DatumFromQuery) -> OutputDatum
toPlutusOutputDatum (Maybe (DatumHash, DatumFromQuery) -> OutputDatum)
-> Maybe (DatumHash, DatumFromQuery) -> OutputDatum
forall a b. (a -> b) -> a -> b
$ DecoratedTxOut
p DecoratedTxOut
-> Getting
(First (DatumHash, DatumFromQuery))
DecoratedTxOut
(DatumHash, DatumFromQuery)
-> Maybe (DatumHash, DatumFromQuery)
forall s a. s -> Getting (First a) s a -> Maybe a
^? Getting
(First (DatumHash, DatumFromQuery))
DecoratedTxOut
(DatumHash, DatumFromQuery)
Traversal' DecoratedTxOut (DatumHash, DatumFromQuery)
decoratedTxOutDatum)
(LensLike'
(Const (Maybe ScriptHash))
DecoratedTxOut
(Maybe (Versioned Script))
-> (Maybe (Versioned Script) -> Maybe ScriptHash)
-> DecoratedTxOut
-> Maybe ScriptHash
forall s (m :: * -> *) r a.
MonadReader s m =>
LensLike' (Const r) s a -> (a -> r) -> m r
views LensLike'
(Const (Maybe ScriptHash))
DecoratedTxOut
(Maybe (Versioned Script))
Lens' DecoratedTxOut (Maybe (Versioned Script))
decoratedTxOutReferenceScript ((Versioned Script -> ScriptHash)
-> Maybe (Versioned Script) -> Maybe ScriptHash
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Versioned Script -> ScriptHash
scriptHash) DecoratedTxOut
p)
toPlutusOutputDatum :: Maybe (V2.DatumHash, DatumFromQuery) -> V2.Tx.OutputDatum
toPlutusOutputDatum :: Maybe (DatumHash, DatumFromQuery) -> OutputDatum
toPlutusOutputDatum Maybe (DatumHash, DatumFromQuery)
Nothing = OutputDatum
V2.Tx.NoOutputDatum
toPlutusOutputDatum (Just (DatumHash
_, DatumInline Datum
d)) = Datum -> OutputDatum
V2.Tx.OutputDatum Datum
d
toPlutusOutputDatum (Just (DatumHash
dh, DatumFromQuery
_)) = DatumHash -> OutputDatum
V2.Tx.OutputDatumHash DatumHash
dh
fromDecoratedIndex :: C.Api.NetworkId -> Map TxOutRef DecoratedTxOut -> Either ToCardanoError UtxoIndex
fromDecoratedIndex :: NetworkId
-> Map TxOutRef DecoratedTxOut -> Either ToCardanoError UtxoIndex
fromDecoratedIndex NetworkId
networkId Map TxOutRef DecoratedTxOut
m = Map TxIn (TxOut CtxUTxO BabbageEra) -> UtxoIndex
forall era. Map TxIn (TxOut CtxUTxO era) -> UTxO era
C.UTxO (Map TxIn (TxOut CtxUTxO BabbageEra) -> UtxoIndex)
-> ([(TxIn, TxOut CtxUTxO BabbageEra)]
-> Map TxIn (TxOut CtxUTxO BabbageEra))
-> [(TxIn, TxOut CtxUTxO BabbageEra)]
-> UtxoIndex
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(TxIn, TxOut CtxUTxO BabbageEra)]
-> Map TxIn (TxOut CtxUTxO BabbageEra)
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(TxIn, TxOut CtxUTxO BabbageEra)] -> UtxoIndex)
-> Either ToCardanoError [(TxIn, TxOut CtxUTxO BabbageEra)]
-> Either ToCardanoError UtxoIndex
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> ((TxOutRef, DecoratedTxOut)
-> Either ToCardanoError (TxIn, TxOut CtxUTxO BabbageEra))
-> [(TxOutRef, DecoratedTxOut)]
-> Either ToCardanoError [(TxIn, TxOut CtxUTxO BabbageEra)]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
traverse (TxOutRef, DecoratedTxOut)
-> Either ToCardanoError (TxIn, TxOut CtxUTxO BabbageEra)
toCardanoUtxo (Map TxOutRef DecoratedTxOut -> [(TxOutRef, DecoratedTxOut)]
forall k a. Map k a -> [(k, a)]
Map.toList Map TxOutRef DecoratedTxOut
m)
where
toCardanoUtxo :: (TxOutRef, DecoratedTxOut)
-> Either ToCardanoError (TxIn, TxOut CtxUTxO BabbageEra)
toCardanoUtxo (TxOutRef
outRef, DecoratedTxOut
txOut) = do
TxOut CtxUTxO BabbageEra
txOut' <- TxOut -> TxOut CtxUTxO BabbageEra
toCtxUTxOTxOut (TxOut -> TxOut CtxUTxO BabbageEra)
-> Either ToCardanoError TxOut
-> Either ToCardanoError (TxOut CtxUTxO BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> NetworkId -> DecoratedTxOut -> Either ToCardanoError TxOut
toTxOut NetworkId
networkId DecoratedTxOut
txOut
TxIn
txIn <- TxOutRef -> Either ToCardanoError TxIn
CardanoAPI.toCardanoTxIn TxOutRef
outRef
(TxIn, TxOut CtxUTxO BabbageEra)
-> Either ToCardanoError (TxIn, TxOut CtxUTxO BabbageEra)
forall (f :: * -> *) a. Applicative f => a -> f a
pure (TxIn
txIn, TxOut CtxUTxO BabbageEra
txOut')
instance Pretty DecoratedTxOut where
pretty :: DecoratedTxOut -> Doc ann
pretty DecoratedTxOut
p =
Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 (Doc ann -> Doc ann) -> Doc ann -> Doc ann
forall a b. (a -> b) -> a -> b
$ [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep [ Doc ann
"-" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Value -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (DecoratedTxOut
p DecoratedTxOut -> Getting Value DecoratedTxOut Value -> Value
forall s a. s -> Getting a s a -> a
^. Getting Value DecoratedTxOut Value
Lens' DecoratedTxOut Value
decoratedTxOutValue) Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
"addressed to"
, Address -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (DecoratedTxOut
p DecoratedTxOut -> Getting Address DecoratedTxOut Address -> Address
forall s a. s -> Getting a s a -> a
^. Getting Address DecoratedTxOut Address
Getter DecoratedTxOut Address
decoratedTxOutAddress)]
instance Pretty CardanoTx where
pretty :: CardanoTx -> Doc ann
pretty CardanoTx
tx =
let
renderScriptWitnesses :: CardanoTx -> [Doc ann]
renderScriptWitnesses (CardanoEmulatorEraTx (C.Api.Tx (C.Api.ShelleyTxBody ShelleyBasedEra BabbageEra
_ TxBody (ShelleyLedgerEra BabbageEra)
_ [Script (ShelleyLedgerEra BabbageEra)]
scripts TxBodyScriptData BabbageEra
_ Maybe (AuxiliaryData (ShelleyLedgerEra BabbageEra))
_ TxScriptValidity BabbageEra
_) [KeyWitness BabbageEra]
_)) =
[ Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"attached scripts:"Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: (Script (BabbageEra StandardCrypto) -> Doc ann)
-> [Script (BabbageEra StandardCrypto)] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Script (BabbageEra StandardCrypto) -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow [Script (ShelleyLedgerEra BabbageEra)]
[Script (BabbageEra StandardCrypto)]
scripts)) | Bool -> Bool
not ([Script (BabbageEra StandardCrypto)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Script (ShelleyLedgerEra BabbageEra)]
[Script (BabbageEra StandardCrypto)]
scripts) ]
lines' :: [Doc ann]
lines' =
[ Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"inputs:" Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: (TxIn -> Doc ann) -> [TxIn] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc ann
"-" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+>) (Doc ann -> Doc ann) -> (TxIn -> Doc ann) -> TxIn -> Doc ann
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIn -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty) (CardanoTx -> [TxIn]
getCardanoTxInputs CardanoTx
tx)))
, Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"reference inputs:" Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: (TxIn -> Doc ann) -> [TxIn] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc ann
"-" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+>) (Doc ann -> Doc ann) -> (TxIn -> Doc ann) -> TxIn -> Doc ann
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIn -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty) (CardanoTx -> [TxIn]
getCardanoTxReferenceInputs CardanoTx
tx)))
, Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"collateral inputs:" Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: (TxIn -> Doc ann) -> [TxIn] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap ((Doc ann
"-" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+>) (Doc ann -> Doc ann) -> (TxIn -> Doc ann) -> TxIn -> Doc ann
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxIn -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty) (CardanoTx -> [TxIn]
getCardanoTxCollateralInputs CardanoTx
tx)))
, Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"outputs:" Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: (TxOut -> Doc ann) -> [TxOut] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap TxOut -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (CardanoTx -> [TxOut]
getCardanoTxOutputs CardanoTx
tx)))
]
[Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> [Doc ann] -> (TxOut -> [Doc ann]) -> Maybe TxOut -> [Doc ann]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\TxOut
out -> [Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep [Doc ann
"return collateral:", TxOut -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty TxOut
out])]) (CardanoTx -> Maybe TxOut
getCardanoTxReturnCollateral CardanoTx
tx)
[Doc ann] -> [Doc ann] -> [Doc ann]
forall a. Semigroup a => a -> a -> a
<> [Doc ann] -> (Lovelace -> [Doc ann]) -> Maybe Lovelace -> [Doc ann]
forall b a. b -> (a -> b) -> Maybe a -> b
maybe [] (\Lovelace
val -> [Doc ann
"total collateral:" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Lovelace -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Lovelace
val]) (CardanoTx -> Maybe Lovelace
getCardanoTxTotalCollateral CardanoTx
tx)
[Doc ann] -> [Doc ann] -> [Doc ann]
forall a. [a] -> [a] -> [a]
++ [ Doc ann
"mint:" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Value -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (CardanoTx -> Value
getCardanoTxMint CardanoTx
tx)
, Doc ann
"fee:" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Lovelace -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (CardanoTx -> Lovelace
getCardanoTxFee CardanoTx
tx)
, Doc ann
"validity range:" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> SlotRange -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow (CardanoTx -> SlotRange
getCardanoTxValidityRange CardanoTx
tx)
, Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"data:"Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: ((DatumHash, Datum) -> Doc ann)
-> [(DatumHash, Datum)] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (DatumHash, Datum) -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (Map DatumHash Datum -> [(DatumHash, Datum)]
forall k a. Map k a -> [(k, a)]
Map.toList (CardanoTx -> Map DatumHash Datum
getCardanoTxData CardanoTx
tx))))
, Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"redeemers:"Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: ((RedeemerPtr, Redeemer) -> Doc ann)
-> [(RedeemerPtr, Redeemer)] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (\(RedeemerPtr
k, V2.Redeemer BuiltinData
red) -> RedeemerPtr -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow RedeemerPtr
k Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> Doc ann
":" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> BuiltinData -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow BuiltinData
red) (Map RedeemerPtr Redeemer -> [(RedeemerPtr, Redeemer)]
forall k a. Map k a -> [(k, a)]
Map.toList (Map RedeemerPtr Redeemer -> [(RedeemerPtr, Redeemer)])
-> Map RedeemerPtr Redeemer -> [(RedeemerPtr, Redeemer)]
forall a b. (a -> b) -> a -> b
$ CardanoTx -> Map RedeemerPtr Redeemer
getCardanoTxRedeemers CardanoTx
tx)))
] [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. [a] -> [a] -> [a]
++
[ Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
hang Int
2 ([Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep (Doc ann
"required signatures:"Doc ann -> [Doc ann] -> [Doc ann]
forall a. a -> [a] -> [a]
: (Hash PaymentKey -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow (Hash PaymentKey -> Doc ann) -> [Hash PaymentKey] -> [Doc ann]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Hash PaymentKey]
wits))) | let wits :: [Hash PaymentKey]
wits = CardanoTx -> [Hash PaymentKey]
getCardanoTxExtraKeyWitnesses CardanoTx
tx, Bool -> Bool
not ([Hash PaymentKey] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null [Hash PaymentKey]
wits)
] [Doc ann] -> [Doc ann] -> [Doc ann]
forall a. [a] -> [a] -> [a]
++ CardanoTx -> [Doc ann]
forall ann. CardanoTx -> [Doc ann]
renderScriptWitnesses CardanoTx
tx
in Int -> Doc ann -> Doc ann
forall ann. Int -> Doc ann -> Doc ann
nest Int
2 (Doc ann -> Doc ann) -> Doc ann -> Doc ann
forall a b. (a -> b) -> a -> b
$ [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep [Doc ann
"Tx" Doc ann -> Doc ann -> Doc ann
forall ann. Doc ann -> Doc ann -> Doc ann
<+> TxId -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (CardanoTx -> TxId
getCardanoTxId CardanoTx
tx) Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
forall ann. Doc ann
colon, [Doc ann] -> Doc ann
forall ann. [Doc ann] -> Doc ann
vsep [Doc ann]
lines']
instance Pretty CardanoAPI.CardanoBuildTx where
pretty :: CardanoBuildTx -> Doc ann
pretty CardanoBuildTx
txBodyContent = case [KeyWitness BabbageEra] -> TxBody BabbageEra -> Tx BabbageEra
forall era. [KeyWitness era] -> TxBody era -> Tx era
C.makeSignedTransaction [] (TxBody BabbageEra -> Tx BabbageEra)
-> Either ToCardanoError (TxBody BabbageEra)
-> Either ToCardanoError (Tx BabbageEra)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (PParams (BabbageEra StandardCrypto))
-> Map RdmrPtr ExUnits
-> CardanoBuildTx
-> Either ToCardanoError (TxBody BabbageEra)
CardanoAPI.makeTransactionBody Maybe (PParams (BabbageEra StandardCrypto))
forall a. Maybe a
Nothing Map RdmrPtr ExUnits
forall a. Monoid a => a
mempty CardanoBuildTx
txBodyContent of
Right Tx BabbageEra
tx -> CardanoTx -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty (CardanoTx -> Doc ann) -> CardanoTx -> Doc ann
forall a b. (a -> b) -> a -> b
$ Tx BabbageEra -> CardanoTx
CardanoEmulatorEraTx Tx BabbageEra
tx
Either ToCardanoError (Tx BabbageEra)
_ -> CardanoBuildTx -> Doc ann
forall a ann. Show a => a -> Doc ann
viaShow CardanoBuildTx
txBodyContent
getTxBodyContent :: CardanoTx -> C.TxBodyContent C.ViewTx C.BabbageEra
getTxBodyContent :: CardanoTx -> TxBodyContent ViewTx BabbageEra
getTxBodyContent (CardanoEmulatorEraTx (C.Tx (C.TxBody TxBodyContent ViewTx BabbageEra
bodyContent) [KeyWitness BabbageEra]
_)) = TxBodyContent ViewTx BabbageEra
bodyContent
getCardanoTxId :: CardanoTx -> C.TxId
getCardanoTxId :: CardanoTx -> TxId
getCardanoTxId = CardanoTx -> TxId
getCardanoApiTxId
getCardanoApiTxId :: CardanoTx -> C.TxId
getCardanoApiTxId :: CardanoTx -> TxId
getCardanoApiTxId (CardanoTx (C.Tx TxBody era
body [KeyWitness era]
_) EraInMode era CardanoMode
_) = TxBody era -> TxId
forall era. TxBody era -> TxId
C.getTxId TxBody era
body
getCardanoTxInputs :: CardanoTx -> [C.TxIn]
getCardanoTxInputs :: CardanoTx -> [TxIn]
getCardanoTxInputs = TxBodyContent ViewTx BabbageEra -> [TxIn]
forall ctx era. TxBodyContent ctx era -> [TxIn]
getTxBodyContentInputs (TxBodyContent ViewTx BabbageEra -> [TxIn])
-> (CardanoTx -> TxBodyContent ViewTx BabbageEra)
-> CardanoTx
-> [TxIn]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> TxBodyContent ViewTx BabbageEra
getTxBodyContent
getTxBodyContentInputs :: C.TxBodyContent ctx era -> [C.TxIn]
getTxBodyContentInputs :: TxBodyContent ctx era -> [TxIn]
getTxBodyContentInputs C.TxBodyContent {TxIns ctx era
[TxOut CtxTx era]
(TxValidityLowerBound era, TxValidityUpperBound era)
BuildTxWith ctx (Maybe ProtocolParameters)
TxAuxScripts era
TxCertificates ctx era
TxExtraKeyWitnesses era
TxFee era
TxInsCollateral era
TxInsReference ctx era
TxMetadataInEra era
TxMintValue ctx era
TxReturnCollateral CtxTx era
TxScriptValidity era
TxTotalCollateral era
TxUpdateProposal era
TxWithdrawals ctx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
txScriptValidity :: TxScriptValidity era
txMintValue :: TxMintValue ctx era
txUpdateProposal :: TxUpdateProposal era
txCertificates :: TxCertificates ctx era
txWithdrawals :: TxWithdrawals ctx era
txProtocolParams :: BuildTxWith ctx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses era
txAuxScripts :: TxAuxScripts era
txMetadata :: TxMetadataInEra era
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txFee :: TxFee era
txReturnCollateral :: TxReturnCollateral CtxTx era
txTotalCollateral :: TxTotalCollateral era
txOuts :: [TxOut CtxTx era]
txInsReference :: TxInsReference ctx era
txInsCollateral :: TxInsCollateral era
txIns :: TxIns ctx era
..} =
((TxIn, BuildTxWith ctx (Witness WitCtxTxIn era)) -> TxIn)
-> TxIns ctx era -> [TxIn]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TxIn, BuildTxWith ctx (Witness WitCtxTxIn era)) -> TxIn
forall a b. (a, b) -> a
fst TxIns ctx era
txIns
getCardanoTxCollateralInputs :: CardanoTx -> [C.TxIn]
getCardanoTxCollateralInputs :: CardanoTx -> [TxIn]
getCardanoTxCollateralInputs = TxBodyContent ViewTx BabbageEra -> [TxIn]
forall ctx era. TxBodyContent ctx era -> [TxIn]
getTxBodyContentCollateralInputs (TxBodyContent ViewTx BabbageEra -> [TxIn])
-> (CardanoTx -> TxBodyContent ViewTx BabbageEra)
-> CardanoTx
-> [TxIn]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> TxBodyContent ViewTx BabbageEra
getTxBodyContent
getTxBodyContentCollateralInputs :: C.TxBodyContent ctx era -> [C.TxIn]
getTxBodyContentCollateralInputs :: TxBodyContent ctx era -> [TxIn]
getTxBodyContentCollateralInputs C.TxBodyContent {TxIns ctx era
[TxOut CtxTx era]
(TxValidityLowerBound era, TxValidityUpperBound era)
BuildTxWith ctx (Maybe ProtocolParameters)
TxAuxScripts era
TxCertificates ctx era
TxExtraKeyWitnesses era
TxFee era
TxInsCollateral era
TxInsReference ctx era
TxMetadataInEra era
TxMintValue ctx era
TxReturnCollateral CtxTx era
TxScriptValidity era
TxTotalCollateral era
TxUpdateProposal era
TxWithdrawals ctx era
txScriptValidity :: TxScriptValidity era
txMintValue :: TxMintValue ctx era
txUpdateProposal :: TxUpdateProposal era
txCertificates :: TxCertificates ctx era
txWithdrawals :: TxWithdrawals ctx era
txProtocolParams :: BuildTxWith ctx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses era
txAuxScripts :: TxAuxScripts era
txMetadata :: TxMetadataInEra era
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txFee :: TxFee era
txReturnCollateral :: TxReturnCollateral CtxTx era
txTotalCollateral :: TxTotalCollateral era
txOuts :: [TxOut CtxTx era]
txInsReference :: TxInsReference ctx era
txInsCollateral :: TxInsCollateral era
txIns :: TxIns ctx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..} = TxInsCollateral era -> [TxIn]
forall era. TxInsCollateral era -> [TxIn]
CardanoAPI.fromCardanoTxInsCollateral TxInsCollateral era
txInsCollateral
getCardanoTxReferenceInputs :: CardanoTx -> [C.TxIn]
getCardanoTxReferenceInputs :: CardanoTx -> [TxIn]
getCardanoTxReferenceInputs (CardanoTx (C.Tx (C.TxBody C.TxBodyContent {TxIns ViewTx era
[TxOut CtxTx era]
(TxValidityLowerBound era, TxValidityUpperBound era)
BuildTxWith ViewTx (Maybe ProtocolParameters)
TxAuxScripts era
TxCertificates ViewTx era
TxExtraKeyWitnesses era
TxFee era
TxInsCollateral era
TxInsReference ViewTx era
TxMetadataInEra era
TxMintValue ViewTx era
TxReturnCollateral CtxTx era
TxScriptValidity era
TxTotalCollateral era
TxUpdateProposal era
TxWithdrawals ViewTx era
txScriptValidity :: TxScriptValidity era
txMintValue :: TxMintValue ViewTx era
txUpdateProposal :: TxUpdateProposal era
txCertificates :: TxCertificates ViewTx era
txWithdrawals :: TxWithdrawals ViewTx era
txProtocolParams :: BuildTxWith ViewTx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses era
txAuxScripts :: TxAuxScripts era
txMetadata :: TxMetadataInEra era
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txFee :: TxFee era
txReturnCollateral :: TxReturnCollateral CtxTx era
txTotalCollateral :: TxTotalCollateral era
txOuts :: [TxOut CtxTx era]
txInsReference :: TxInsReference ViewTx era
txInsCollateral :: TxInsCollateral era
txIns :: TxIns ViewTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..}) [KeyWitness era]
_) EraInMode era CardanoMode
_) =
TxInsReference ViewTx era -> [TxIn]
forall build era. TxInsReference build era -> [TxIn]
txInsReferenceToTxIns TxInsReference ViewTx era
txInsReference
where
txInsReferenceToTxIns :: TxInsReference build era -> [TxIn]
txInsReferenceToTxIns TxInsReference build era
C.TxInsReferenceNone = []
txInsReferenceToTxIns (C.TxInsReference ReferenceTxInsScriptsInlineDatumsSupportedInEra era
_ [TxIn]
txIns') = [TxIn]
txIns'
getCardanoTxOutRefs :: CardanoTx -> [(TxOut, C.TxIn)]
getCardanoTxOutRefs :: CardanoTx -> [(TxOut, TxIn)]
getCardanoTxOutRefs (CardanoEmulatorEraTx (C.Tx txBody :: TxBody BabbageEra
txBody@(C.TxBody C.TxBodyContent{TxIns ViewTx BabbageEra
[TxOut CtxTx BabbageEra]
(TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
BuildTxWith ViewTx (Maybe ProtocolParameters)
TxAuxScripts BabbageEra
TxCertificates ViewTx BabbageEra
TxExtraKeyWitnesses BabbageEra
TxFee BabbageEra
TxInsCollateral BabbageEra
TxInsReference ViewTx BabbageEra
TxMetadataInEra BabbageEra
TxMintValue ViewTx BabbageEra
TxReturnCollateral CtxTx BabbageEra
TxScriptValidity BabbageEra
TxTotalCollateral BabbageEra
TxUpdateProposal BabbageEra
TxWithdrawals ViewTx BabbageEra
txScriptValidity :: TxScriptValidity BabbageEra
txMintValue :: TxMintValue ViewTx BabbageEra
txUpdateProposal :: TxUpdateProposal BabbageEra
txCertificates :: TxCertificates ViewTx BabbageEra
txWithdrawals :: TxWithdrawals ViewTx BabbageEra
txProtocolParams :: BuildTxWith ViewTx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses BabbageEra
txAuxScripts :: TxAuxScripts BabbageEra
txMetadata :: TxMetadataInEra BabbageEra
txValidityRange :: (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
txFee :: TxFee BabbageEra
txReturnCollateral :: TxReturnCollateral CtxTx BabbageEra
txTotalCollateral :: TxTotalCollateral BabbageEra
txOuts :: [TxOut CtxTx BabbageEra]
txInsReference :: TxInsReference ViewTx BabbageEra
txInsCollateral :: TxInsCollateral BabbageEra
txIns :: TxIns ViewTx BabbageEra
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..}) [KeyWitness BabbageEra]
_)) =
(Word, TxOut) -> (TxOut, TxIn)
mkOut ((Word, TxOut) -> (TxOut, TxIn))
-> [(Word, TxOut)] -> [(TxOut, TxIn)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word] -> [TxOut] -> [(Word, TxOut)]
forall a b. [a] -> [b] -> [(a, b)]
zip [Word
0..] ([TxOut CtxTx BabbageEra] -> [TxOut]
coerce [TxOut CtxTx BabbageEra]
txOuts)
where
mkOut :: (Word, TxOut) -> (TxOut, TxIn)
mkOut (Word
i, TxOut
o) = (TxOut
o, TxId -> TxIx -> TxIn
C.TxIn (TxBody BabbageEra -> TxId
forall era. TxBody era -> TxId
C.getTxId TxBody BabbageEra
txBody) (Word -> TxIx
C.TxIx Word
i))
getCardanoTxOutputs :: CardanoTx -> [TxOut]
getCardanoTxOutputs :: CardanoTx -> [TxOut]
getCardanoTxOutputs = ((TxOut, TxIn) -> TxOut) -> [(TxOut, TxIn)] -> [TxOut]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TxOut, TxIn) -> TxOut
forall a b. (a, b) -> a
fst ([(TxOut, TxIn)] -> [TxOut])
-> (CardanoTx -> [(TxOut, TxIn)]) -> CardanoTx -> [TxOut]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> [(TxOut, TxIn)]
getCardanoTxOutRefs
getCardanoTxProducedOutputs :: CardanoTx -> Map C.TxIn TxOut
getCardanoTxProducedOutputs :: CardanoTx -> Map TxIn TxOut
getCardanoTxProducedOutputs = [(TxIn, TxOut)] -> Map TxIn TxOut
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList ([(TxIn, TxOut)] -> Map TxIn TxOut)
-> (CardanoTx -> [(TxIn, TxOut)]) -> CardanoTx -> Map TxIn TxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((TxOut, TxIn) -> (TxIn, TxOut))
-> [(TxOut, TxIn)] -> [(TxIn, TxOut)]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TxOut, TxIn) -> (TxIn, TxOut)
forall a b. (a, b) -> (b, a)
swap ([(TxOut, TxIn)] -> [(TxIn, TxOut)])
-> (CardanoTx -> [(TxOut, TxIn)]) -> CardanoTx -> [(TxIn, TxOut)]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> [(TxOut, TxIn)]
getCardanoTxOutRefs
getCardanoTxSpentOutputs :: CardanoTx -> Set C.TxIn
getCardanoTxSpentOutputs :: CardanoTx -> Set TxIn
getCardanoTxSpentOutputs = [TxIn] -> Set TxIn
forall a. Ord a => [a] -> Set a
Set.fromList ([TxIn] -> Set TxIn)
-> (CardanoTx -> [TxIn]) -> CardanoTx -> Set TxIn
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> [TxIn]
getCardanoTxInputs
getCardanoTxReturnCollateral :: CardanoTx -> Maybe TxOut
getCardanoTxReturnCollateral :: CardanoTx -> Maybe TxOut
getCardanoTxReturnCollateral = TxBodyContent ViewTx BabbageEra -> Maybe TxOut
forall ctx. TxBodyContent ctx BabbageEra -> Maybe TxOut
getTxBodyContentReturnCollateral (TxBodyContent ViewTx BabbageEra -> Maybe TxOut)
-> (CardanoTx -> TxBodyContent ViewTx BabbageEra)
-> CardanoTx
-> Maybe TxOut
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> TxBodyContent ViewTx BabbageEra
getTxBodyContent
getTxBodyContentReturnCollateral :: C.TxBodyContent ctx C.Api.BabbageEra -> Maybe TxOut
getTxBodyContentReturnCollateral :: TxBodyContent ctx BabbageEra -> Maybe TxOut
getTxBodyContentReturnCollateral C.TxBodyContent {TxIns ctx BabbageEra
[TxOut CtxTx BabbageEra]
(TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
BuildTxWith ctx (Maybe ProtocolParameters)
TxAuxScripts BabbageEra
TxCertificates ctx BabbageEra
TxExtraKeyWitnesses BabbageEra
TxFee BabbageEra
TxInsCollateral BabbageEra
TxInsReference ctx BabbageEra
TxMetadataInEra BabbageEra
TxMintValue ctx BabbageEra
TxReturnCollateral CtxTx BabbageEra
TxScriptValidity BabbageEra
TxTotalCollateral BabbageEra
TxUpdateProposal BabbageEra
TxWithdrawals ctx BabbageEra
txScriptValidity :: TxScriptValidity BabbageEra
txMintValue :: TxMintValue ctx BabbageEra
txUpdateProposal :: TxUpdateProposal BabbageEra
txCertificates :: TxCertificates ctx BabbageEra
txWithdrawals :: TxWithdrawals ctx BabbageEra
txProtocolParams :: BuildTxWith ctx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses BabbageEra
txAuxScripts :: TxAuxScripts BabbageEra
txMetadata :: TxMetadataInEra BabbageEra
txValidityRange :: (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
txFee :: TxFee BabbageEra
txReturnCollateral :: TxReturnCollateral CtxTx BabbageEra
txTotalCollateral :: TxTotalCollateral BabbageEra
txOuts :: [TxOut CtxTx BabbageEra]
txInsReference :: TxInsReference ctx BabbageEra
txInsCollateral :: TxInsCollateral BabbageEra
txIns :: TxIns ctx BabbageEra
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..} =
case TxReturnCollateral CtxTx BabbageEra
txReturnCollateral of
TxReturnCollateral CtxTx BabbageEra
C.TxReturnCollateralNone -> Maybe TxOut
forall a. Maybe a
Nothing
C.TxReturnCollateral TxTotalAndReturnCollateralSupportedInEra BabbageEra
_ TxOut CtxTx BabbageEra
txOut -> TxOut -> Maybe TxOut
forall a. a -> Maybe a
Just (TxOut -> Maybe TxOut) -> TxOut -> Maybe TxOut
forall a b. (a -> b) -> a -> b
$ TxOut CtxTx BabbageEra -> TxOut
TxOut TxOut CtxTx BabbageEra
txOut
getCardanoTxProducedReturnCollateral :: CardanoTx -> Map C.TxIn TxOut
getCardanoTxProducedReturnCollateral :: CardanoTx -> Map TxIn TxOut
getCardanoTxProducedReturnCollateral CardanoTx
tx = Map TxIn TxOut
-> (TxOut -> Map TxIn TxOut) -> Maybe TxOut -> Map TxIn TxOut
forall b a. b -> (a -> b) -> Maybe a -> b
maybe Map TxIn TxOut
forall k a. Map k a
Map.empty (TxIn -> TxOut -> Map TxIn TxOut
forall k a. k -> a -> Map k a
Map.singleton (TxId -> TxIx -> TxIn
C.TxIn (CardanoTx -> TxId
getCardanoTxId CardanoTx
tx) (Word -> TxIx
C.TxIx Word
0))) (Maybe TxOut -> Map TxIn TxOut) -> Maybe TxOut -> Map TxIn TxOut
forall a b. (a -> b) -> a -> b
$
CardanoTx -> Maybe TxOut
getCardanoTxReturnCollateral CardanoTx
tx
getCardanoTxTotalCollateral :: CardanoTx -> Maybe C.Lovelace
getCardanoTxTotalCollateral :: CardanoTx -> Maybe Lovelace
getCardanoTxTotalCollateral (CardanoEmulatorEraTx (C.Tx (C.TxBody C.TxBodyContent {TxIns ViewTx BabbageEra
[TxOut CtxTx BabbageEra]
(TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
BuildTxWith ViewTx (Maybe ProtocolParameters)
TxAuxScripts BabbageEra
TxCertificates ViewTx BabbageEra
TxExtraKeyWitnesses BabbageEra
TxFee BabbageEra
TxInsCollateral BabbageEra
TxInsReference ViewTx BabbageEra
TxMetadataInEra BabbageEra
TxMintValue ViewTx BabbageEra
TxReturnCollateral CtxTx BabbageEra
TxScriptValidity BabbageEra
TxTotalCollateral BabbageEra
TxUpdateProposal BabbageEra
TxWithdrawals ViewTx BabbageEra
txScriptValidity :: TxScriptValidity BabbageEra
txMintValue :: TxMintValue ViewTx BabbageEra
txUpdateProposal :: TxUpdateProposal BabbageEra
txCertificates :: TxCertificates ViewTx BabbageEra
txWithdrawals :: TxWithdrawals ViewTx BabbageEra
txProtocolParams :: BuildTxWith ViewTx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses BabbageEra
txAuxScripts :: TxAuxScripts BabbageEra
txMetadata :: TxMetadataInEra BabbageEra
txValidityRange :: (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
txFee :: TxFee BabbageEra
txReturnCollateral :: TxReturnCollateral CtxTx BabbageEra
txTotalCollateral :: TxTotalCollateral BabbageEra
txOuts :: [TxOut CtxTx BabbageEra]
txInsReference :: TxInsReference ViewTx BabbageEra
txInsCollateral :: TxInsCollateral BabbageEra
txIns :: TxIns ViewTx BabbageEra
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..}) [KeyWitness BabbageEra]
_)) =
TxTotalCollateral BabbageEra -> Maybe Lovelace
CardanoAPI.fromCardanoTotalCollateral TxTotalCollateral BabbageEra
txTotalCollateral
getCardanoTxFee :: CardanoTx -> C.Lovelace
getCardanoTxFee :: CardanoTx -> Lovelace
getCardanoTxFee (CardanoTx (C.Tx (C.TxBody C.TxBodyContent {TxIns ViewTx era
[TxOut CtxTx era]
(TxValidityLowerBound era, TxValidityUpperBound era)
BuildTxWith ViewTx (Maybe ProtocolParameters)
TxAuxScripts era
TxCertificates ViewTx era
TxExtraKeyWitnesses era
TxFee era
TxInsCollateral era
TxInsReference ViewTx era
TxMetadataInEra era
TxMintValue ViewTx era
TxReturnCollateral CtxTx era
TxScriptValidity era
TxTotalCollateral era
TxUpdateProposal era
TxWithdrawals ViewTx era
txScriptValidity :: TxScriptValidity era
txMintValue :: TxMintValue ViewTx era
txUpdateProposal :: TxUpdateProposal era
txCertificates :: TxCertificates ViewTx era
txWithdrawals :: TxWithdrawals ViewTx era
txProtocolParams :: BuildTxWith ViewTx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses era
txAuxScripts :: TxAuxScripts era
txMetadata :: TxMetadataInEra era
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txFee :: TxFee era
txReturnCollateral :: TxReturnCollateral CtxTx era
txTotalCollateral :: TxTotalCollateral era
txOuts :: [TxOut CtxTx era]
txInsReference :: TxInsReference ViewTx era
txInsCollateral :: TxInsCollateral era
txIns :: TxIns ViewTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..}) [KeyWitness era]
_) EraInMode era CardanoMode
_) = TxFee era -> Lovelace
forall era. TxFee era -> Lovelace
CardanoAPI.fromCardanoFee TxFee era
txFee
getCardanoTxMint :: CardanoTx -> C.Value
getCardanoTxMint :: CardanoTx -> Value
getCardanoTxMint = TxBodyContent ViewTx BabbageEra -> Value
forall ctx era. TxBodyContent ctx era -> Value
getTxBodyContentMint (TxBodyContent ViewTx BabbageEra -> Value)
-> (CardanoTx -> TxBodyContent ViewTx BabbageEra)
-> CardanoTx
-> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CardanoTx -> TxBodyContent ViewTx BabbageEra
getTxBodyContent
getTxBodyContentMint :: C.TxBodyContent ctx era -> C.Value
getTxBodyContentMint :: TxBodyContent ctx era -> Value
getTxBodyContentMint C.TxBodyContent {TxIns ctx era
[TxOut CtxTx era]
(TxValidityLowerBound era, TxValidityUpperBound era)
BuildTxWith ctx (Maybe ProtocolParameters)
TxAuxScripts era
TxCertificates ctx era
TxExtraKeyWitnesses era
TxFee era
TxInsCollateral era
TxInsReference ctx era
TxMetadataInEra era
TxMintValue ctx era
TxReturnCollateral CtxTx era
TxScriptValidity era
TxTotalCollateral era
TxUpdateProposal era
TxWithdrawals ctx era
txScriptValidity :: TxScriptValidity era
txMintValue :: TxMintValue ctx era
txUpdateProposal :: TxUpdateProposal era
txCertificates :: TxCertificates ctx era
txWithdrawals :: TxWithdrawals ctx era
txProtocolParams :: BuildTxWith ctx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses era
txAuxScripts :: TxAuxScripts era
txMetadata :: TxMetadataInEra era
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txFee :: TxFee era
txReturnCollateral :: TxReturnCollateral CtxTx era
txTotalCollateral :: TxTotalCollateral era
txOuts :: [TxOut CtxTx era]
txInsReference :: TxInsReference ctx era
txInsCollateral :: TxInsCollateral era
txIns :: TxIns ctx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..} = TxMintValue ctx era -> Value
forall build era. TxMintValue build era -> Value
CardanoAPI.fromCardanoMintValue TxMintValue ctx era
txMintValue
getCardanoTxValidityRange :: CardanoTx -> SlotRange
getCardanoTxValidityRange :: CardanoTx -> SlotRange
getCardanoTxValidityRange (CardanoTx (C.Tx (C.TxBody C.TxBodyContent {TxIns ViewTx era
[TxOut CtxTx era]
(TxValidityLowerBound era, TxValidityUpperBound era)
BuildTxWith ViewTx (Maybe ProtocolParameters)
TxAuxScripts era
TxCertificates ViewTx era
TxExtraKeyWitnesses era
TxFee era
TxInsCollateral era
TxInsReference ViewTx era
TxMetadataInEra era
TxMintValue ViewTx era
TxReturnCollateral CtxTx era
TxScriptValidity era
TxTotalCollateral era
TxUpdateProposal era
TxWithdrawals ViewTx era
txScriptValidity :: TxScriptValidity era
txMintValue :: TxMintValue ViewTx era
txUpdateProposal :: TxUpdateProposal era
txCertificates :: TxCertificates ViewTx era
txWithdrawals :: TxWithdrawals ViewTx era
txProtocolParams :: BuildTxWith ViewTx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses era
txAuxScripts :: TxAuxScripts era
txMetadata :: TxMetadataInEra era
txValidityRange :: (TxValidityLowerBound era, TxValidityUpperBound era)
txFee :: TxFee era
txReturnCollateral :: TxReturnCollateral CtxTx era
txTotalCollateral :: TxTotalCollateral era
txOuts :: [TxOut CtxTx era]
txInsReference :: TxInsReference ViewTx era
txInsCollateral :: TxInsCollateral era
txIns :: TxIns ViewTx era
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..}) [KeyWitness era]
_) EraInMode era CardanoMode
_) = (TxValidityLowerBound era, TxValidityUpperBound era) -> SlotRange
forall era.
(TxValidityLowerBound era, TxValidityUpperBound era) -> SlotRange
CardanoAPI.fromCardanoValidityRange (TxValidityLowerBound era, TxValidityUpperBound era)
txValidityRange
getCardanoTxData :: CardanoTx -> Map V1.DatumHash V1.Datum
getCardanoTxData :: CardanoTx -> Map DatumHash Datum
getCardanoTxData (CardanoTx (C.Tx TxBody era
txBody [KeyWitness era]
_) EraInMode era CardanoMode
_) = (Map DatumHash Datum, Map RedeemerPtr Redeemer)
-> Map DatumHash Datum
forall a b. (a, b) -> a
fst ((Map DatumHash Datum, Map RedeemerPtr Redeemer)
-> Map DatumHash Datum)
-> (Map DatumHash Datum, Map RedeemerPtr Redeemer)
-> Map DatumHash Datum
forall a b. (a -> b) -> a -> b
$ TxBody era -> (Map DatumHash Datum, Map RedeemerPtr Redeemer)
forall era.
TxBody era -> (Map DatumHash Datum, Map RedeemerPtr Redeemer)
CardanoAPI.scriptDataFromCardanoTxBody TxBody era
txBody
txBodyContentIns :: Lens' (C.TxBodyContent C.BuildTx C.BabbageEra) [(C.TxIn, C.BuildTxWith C.BuildTx (C.Witness C.WitCtxTxIn C.BabbageEra))]
txBodyContentIns :: ([(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
-> f [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))])
-> TxBodyContent BuildTx BabbageEra
-> f (TxBodyContent BuildTx BabbageEra)
txBodyContentIns = (TxBodyContent BuildTx BabbageEra
-> [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))])
-> (TxBodyContent BuildTx BabbageEra
-> [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
-> TxBodyContent BuildTx BabbageEra)
-> Lens
(TxBodyContent BuildTx BabbageEra)
(TxBodyContent BuildTx BabbageEra)
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
[(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens TxBodyContent BuildTx BabbageEra
-> [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
forall build era. TxBodyContent build era -> TxIns build era
C.txIns (\TxBodyContent BuildTx BabbageEra
bodyContent [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
ins -> TxBodyContent BuildTx BabbageEra
bodyContent { txIns :: [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
C.txIns = [(TxIn, BuildTxWith BuildTx (Witness WitCtxTxIn BabbageEra))]
ins })
txBodyContentCollateralIns :: Lens' (C.TxBodyContent C.BuildTx C.BabbageEra) [C.TxIn]
txBodyContentCollateralIns :: ([TxIn] -> f [TxIn])
-> TxBodyContent BuildTx BabbageEra
-> f (TxBodyContent BuildTx BabbageEra)
txBodyContentCollateralIns = (TxBodyContent BuildTx BabbageEra -> [TxIn])
-> (TxBodyContent BuildTx BabbageEra
-> [TxIn] -> TxBodyContent BuildTx BabbageEra)
-> Lens
(TxBodyContent BuildTx BabbageEra)
(TxBodyContent BuildTx BabbageEra)
[TxIn]
[TxIn]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens
(\TxBodyContent BuildTx BabbageEra
bodyContent -> case TxBodyContent BuildTx BabbageEra -> TxInsCollateral BabbageEra
forall build era. TxBodyContent build era -> TxInsCollateral era
C.txInsCollateral TxBodyContent BuildTx BabbageEra
bodyContent of TxInsCollateral BabbageEra
C.TxInsCollateralNone -> []; C.TxInsCollateral CollateralSupportedInEra BabbageEra
_ [TxIn]
txIns -> [TxIn]
txIns)
(\TxBodyContent BuildTx BabbageEra
bodyContent [TxIn]
ins -> TxBodyContent BuildTx BabbageEra
bodyContent { txInsCollateral :: TxInsCollateral BabbageEra
C.txInsCollateral = case [TxIn]
ins of [] -> TxInsCollateral BabbageEra
forall era. TxInsCollateral era
C.TxInsCollateralNone; [TxIn]
_ -> CollateralSupportedInEra BabbageEra
-> [TxIn] -> TxInsCollateral BabbageEra
forall era.
CollateralSupportedInEra era -> [TxIn] -> TxInsCollateral era
C.TxInsCollateral CollateralSupportedInEra BabbageEra
C.CollateralInBabbageEra [TxIn]
ins })
txBodyContentOuts :: Lens' (C.TxBodyContent ctx C.BabbageEra) [TxOut]
txBodyContentOuts :: ([TxOut] -> f [TxOut])
-> TxBodyContent ctx BabbageEra -> f (TxBodyContent ctx BabbageEra)
txBodyContentOuts = (TxBodyContent ctx BabbageEra -> [TxOut])
-> (TxBodyContent ctx BabbageEra
-> [TxOut] -> TxBodyContent ctx BabbageEra)
-> Lens
(TxBodyContent ctx BabbageEra)
(TxBodyContent ctx BabbageEra)
[TxOut]
[TxOut]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens ((TxOut CtxTx BabbageEra -> TxOut)
-> [TxOut CtxTx BabbageEra] -> [TxOut]
forall a b. (a -> b) -> [a] -> [b]
map TxOut CtxTx BabbageEra -> TxOut
TxOut ([TxOut CtxTx BabbageEra] -> [TxOut])
-> (TxBodyContent ctx BabbageEra -> [TxOut CtxTx BabbageEra])
-> TxBodyContent ctx BabbageEra
-> [TxOut]
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxBodyContent ctx BabbageEra -> [TxOut CtxTx BabbageEra]
forall build era. TxBodyContent build era -> [TxOut CtxTx era]
C.txOuts) (\TxBodyContent ctx BabbageEra
bodyContent [TxOut]
outs -> TxBodyContent ctx BabbageEra
bodyContent { txOuts :: [TxOut CtxTx BabbageEra]
C.txOuts = (TxOut -> TxOut CtxTx BabbageEra)
-> [TxOut] -> [TxOut CtxTx BabbageEra]
forall a b. (a -> b) -> [a] -> [b]
map TxOut -> TxOut CtxTx BabbageEra
getTxOut [TxOut]
outs })
getCardanoTxRedeemers :: CardanoTx -> V2.Tx.Redeemers
getCardanoTxRedeemers :: CardanoTx -> Map RedeemerPtr Redeemer
getCardanoTxRedeemers (CardanoTx (C.Tx TxBody era
txBody [KeyWitness era]
_) EraInMode era CardanoMode
_) = (Map DatumHash Datum, Map RedeemerPtr Redeemer)
-> Map RedeemerPtr Redeemer
forall a b. (a, b) -> b
snd ((Map DatumHash Datum, Map RedeemerPtr Redeemer)
-> Map RedeemerPtr Redeemer)
-> (Map DatumHash Datum, Map RedeemerPtr Redeemer)
-> Map RedeemerPtr Redeemer
forall a b. (a -> b) -> a -> b
$ TxBody era -> (Map DatumHash Datum, Map RedeemerPtr Redeemer)
forall era.
TxBody era -> (Map DatumHash Datum, Map RedeemerPtr Redeemer)
CardanoAPI.scriptDataFromCardanoTxBody TxBody era
txBody
getCardanoTxExtraKeyWitnesses :: CardanoTx -> [C.Hash C.PaymentKey]
(CardanoEmulatorEraTx (C.Tx (C.TxBody C.TxBodyContent {TxIns ViewTx BabbageEra
[TxOut CtxTx BabbageEra]
(TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
BuildTxWith ViewTx (Maybe ProtocolParameters)
TxAuxScripts BabbageEra
TxCertificates ViewTx BabbageEra
TxExtraKeyWitnesses BabbageEra
TxFee BabbageEra
TxInsCollateral BabbageEra
TxInsReference ViewTx BabbageEra
TxMetadataInEra BabbageEra
TxMintValue ViewTx BabbageEra
TxReturnCollateral CtxTx BabbageEra
TxScriptValidity BabbageEra
TxTotalCollateral BabbageEra
TxUpdateProposal BabbageEra
TxWithdrawals ViewTx BabbageEra
txScriptValidity :: TxScriptValidity BabbageEra
txMintValue :: TxMintValue ViewTx BabbageEra
txUpdateProposal :: TxUpdateProposal BabbageEra
txCertificates :: TxCertificates ViewTx BabbageEra
txWithdrawals :: TxWithdrawals ViewTx BabbageEra
txProtocolParams :: BuildTxWith ViewTx (Maybe ProtocolParameters)
txExtraKeyWits :: TxExtraKeyWitnesses BabbageEra
txAuxScripts :: TxAuxScripts BabbageEra
txMetadata :: TxMetadataInEra BabbageEra
txValidityRange :: (TxValidityLowerBound BabbageEra, TxValidityUpperBound BabbageEra)
txFee :: TxFee BabbageEra
txReturnCollateral :: TxReturnCollateral CtxTx BabbageEra
txTotalCollateral :: TxTotalCollateral BabbageEra
txOuts :: [TxOut CtxTx BabbageEra]
txInsReference :: TxInsReference ViewTx BabbageEra
txInsCollateral :: TxInsCollateral BabbageEra
txIns :: TxIns ViewTx BabbageEra
txWithdrawals :: forall build era.
TxBodyContent build era -> TxWithdrawals build era
txValidityRange :: forall build era.
TxBodyContent build era
-> (TxValidityLowerBound era, TxValidityUpperBound era)
txUpdateProposal :: forall build era. TxBodyContent build era -> TxUpdateProposal era
txTotalCollateral :: forall build era. TxBodyContent build era -> TxTotalCollateral era
txScriptValidity :: forall build era. TxBodyContent build era -> TxScriptValidity era
txReturnCollateral :: forall build era.
TxBodyContent build era -> TxReturnCollateral CtxTx era
txProtocolParams :: forall build era.
TxBodyContent build era
-> BuildTxWith build (Maybe ProtocolParameters)
txOuts :: forall build era. TxBodyContent build era -> [TxOut CtxTx era]
txMintValue :: forall build era. TxBodyContent build era -> TxMintValue build era
txMetadata :: forall build era. TxBodyContent build era -> TxMetadataInEra era
txInsReference :: forall build era.
TxBodyContent build era -> TxInsReference build era
txInsCollateral :: forall build era. TxBodyContent build era -> TxInsCollateral era
txIns :: forall build era. TxBodyContent build era -> TxIns build era
txFee :: forall build era. TxBodyContent build era -> TxFee era
txExtraKeyWits :: forall build era.
TxBodyContent build era -> TxExtraKeyWitnesses era
txCertificates :: forall build era.
TxBodyContent build era -> TxCertificates build era
txAuxScripts :: forall build era. TxBodyContent build era -> TxAuxScripts era
..}) [KeyWitness BabbageEra]
_)) = case TxExtraKeyWitnesses BabbageEra
txExtraKeyWits of
TxExtraKeyWitnesses BabbageEra
C.Api.TxExtraKeyWitnessesNone -> [Hash PaymentKey]
forall a. Monoid a => a
mempty
C.Api.TxExtraKeyWitnesses TxExtraKeyWitnessesSupportedInEra BabbageEra
_ [Hash PaymentKey]
txwits -> [Hash PaymentKey]
txwits
type PrivateKey = Crypto.XPrv
addCardanoTxSignature :: PrivateKey -> CardanoTx -> CardanoTx
addCardanoTxSignature :: PrivateKey -> CardanoTx -> CardanoTx
addCardanoTxSignature PrivateKey
privKey = CardanoTx -> CardanoTx
addSignatureCardano
where
addSignatureCardano :: CardanoTx -> CardanoTx
addSignatureCardano :: CardanoTx -> CardanoTx
addSignatureCardano (CardanoEmulatorEraTx Tx BabbageEra
ctx)
= Tx BabbageEra -> CardanoTx
CardanoEmulatorEraTx (Tx BabbageEra -> Tx BabbageEra
addSignatureCardano' Tx BabbageEra
ctx)
addSignatureCardano' :: Tx BabbageEra -> Tx BabbageEra
addSignatureCardano' (C.Api.ShelleyTx ShelleyBasedEra BabbageEra
shelleyBasedEra (ValidatedTx body wits isValid aux))
= ShelleyBasedEra BabbageEra
-> Tx (ShelleyLedgerEra BabbageEra) -> Tx BabbageEra
forall era.
ShelleyBasedEra era -> Tx (ShelleyLedgerEra era) -> Tx era
C.Api.ShelleyTx ShelleyBasedEra BabbageEra
shelleyBasedEra (TxBody (BabbageEra StandardCrypto)
-> TxWitness (BabbageEra StandardCrypto)
-> IsValid
-> StrictMaybe (AuxiliaryData (BabbageEra StandardCrypto))
-> ValidatedTx (BabbageEra StandardCrypto)
forall era.
TxBody era
-> TxWitness era
-> IsValid
-> StrictMaybe (AuxiliaryData era)
-> ValidatedTx era
ValidatedTx TxBody (BabbageEra StandardCrypto)
body TxWitness (BabbageEra StandardCrypto)
wits' IsValid
isValid StrictMaybe (AuxiliaryData (BabbageEra StandardCrypto))
aux)
where
wits' :: TxWitness (BabbageEra StandardCrypto)
wits' = TxWitness (BabbageEra StandardCrypto)
wits TxWitness (BabbageEra StandardCrypto)
-> TxWitness (BabbageEra StandardCrypto)
-> TxWitness (BabbageEra StandardCrypto)
forall a. Semigroup a => a -> a -> a
<> TxWitness (BabbageEra StandardCrypto)
forall a. Monoid a => a
mempty { txwitsVKey :: Set (WitVKey 'Witness (Crypto (BabbageEra StandardCrypto)))
txwitsVKey = Set (WitVKey 'Witness StandardCrypto)
Set (WitVKey 'Witness (Crypto (BabbageEra StandardCrypto)))
newWits }
newWits :: Set (WitVKey 'Witness StandardCrypto)
newWits = case PrivateKey
-> TxBody (BabbageEra StandardCrypto) -> KeyWitness BabbageEra
fromPaymentPrivateKey PrivateKey
privKey TxBody (BabbageEra StandardCrypto)
TxBody (BabbageEra StandardCrypto)
body of
C.Api.ShelleyKeyWitness ShelleyBasedEra BabbageEra
_ WitVKey 'Witness StandardCrypto
wit -> WitVKey 'Witness StandardCrypto
-> Set (WitVKey 'Witness StandardCrypto)
forall a. a -> Set a
Set.singleton WitVKey 'Witness StandardCrypto
wit
KeyWitness BabbageEra
_ -> Set (WitVKey 'Witness StandardCrypto)
forall a. Set a
Set.empty
fromPaymentPrivateKey :: PrivateKey
-> TxBody (BabbageEra StandardCrypto) -> KeyWitness BabbageEra
fromPaymentPrivateKey PrivateKey
xprv TxBody (BabbageEra StandardCrypto)
txBody
= TxBody BabbageEra
-> ShelleyWitnessSigningKey -> KeyWitness BabbageEra
forall era.
IsShelleyBasedEra era =>
TxBody era -> ShelleyWitnessSigningKey -> KeyWitness era
C.Api.makeShelleyKeyWitness
(ShelleyBasedEra BabbageEra
-> TxBody (ShelleyLedgerEra BabbageEra)
-> [Script (ShelleyLedgerEra BabbageEra)]
-> TxBodyScriptData BabbageEra
-> Maybe (AuxiliaryData (ShelleyLedgerEra BabbageEra))
-> TxScriptValidity BabbageEra
-> TxBody BabbageEra
forall era.
ShelleyBasedEra era
-> TxBody (ShelleyLedgerEra era)
-> [Script (ShelleyLedgerEra era)]
-> TxBodyScriptData era
-> Maybe (AuxiliaryData (ShelleyLedgerEra era))
-> TxScriptValidity era
-> TxBody era
C.Api.ShelleyTxBody ShelleyBasedEra BabbageEra
C.Api.ShelleyBasedEraBabbage TxBody (ShelleyLedgerEra BabbageEra)
TxBody (BabbageEra StandardCrypto)
txBody [Script (ShelleyLedgerEra BabbageEra)]
forall a. a
notUsed TxBodyScriptData BabbageEra
forall a. a
notUsed Maybe (AuxiliaryData (ShelleyLedgerEra BabbageEra))
forall a. a
notUsed TxScriptValidity BabbageEra
forall a. a
notUsed)
(SigningKey PaymentExtendedKey -> ShelleyWitnessSigningKey
C.Api.WitnessPaymentExtendedKey (PrivateKey -> SigningKey PaymentExtendedKey
C.Api.PaymentExtendedSigningKey PrivateKey
xprv))
where
notUsed :: a
notUsed = a
forall a. HasCallStack => a
undefined
decoratedTxOutPlutusValue :: DecoratedTxOut -> Value
decoratedTxOutPlutusValue :: DecoratedTxOut -> Value
decoratedTxOutPlutusValue = Value -> Value
CardanoAPI.fromCardanoValue (Value -> Value)
-> (DecoratedTxOut -> Value) -> DecoratedTxOut -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Getting Value DecoratedTxOut Value -> DecoratedTxOut -> Value
forall s (m :: * -> *) a. MonadReader s m => Getting a s a -> m a
view Getting Value DecoratedTxOut Value
Lens' DecoratedTxOut Value
decoratedTxOutValue