{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-specialise #-}
{-# OPTIONS_GHC -fno-omit-interface-pragmas #-}
module PlutusLedgerApi.V1.Data.Tx
(
TxId (..)
, ScriptTag (..)
, RedeemerPtr (..)
, Redeemers
, TxOut(..)
, TxOutRef(..)
, isPubKeyOut
, isPayToScriptOut
, outAddress
, outValue
, txOutPubKey
, txOutDatum
, pubKeyHashTxOut
) where
import Control.DeepSeq (NFData)
import Control.Lens
import Data.Map (Map)
import Data.Maybe (isJust)
import Data.String (IsString)
import GHC.Generics (Generic)
import Prettyprinter
import PlutusTx qualified
import PlutusTx.Bool qualified as PlutusTx
import PlutusTx.Builtins qualified as PlutusTx
import PlutusTx.Eq qualified as PlutusTx
import PlutusTx.Ord qualified as PlutusTx
import PlutusLedgerApi.V1.Address
import PlutusLedgerApi.V1.Bytes
import PlutusLedgerApi.V1.Crypto
import PlutusLedgerApi.V1.Data.Value
import PlutusLedgerApi.V1.Scripts
newtype TxId = TxId { TxId -> BuiltinByteString
getTxId :: PlutusTx.BuiltinByteString }
deriving stock (TxId -> TxId -> Bool
(TxId -> TxId -> Bool) -> (TxId -> TxId -> Bool) -> Eq TxId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxId -> TxId -> Bool
== :: TxId -> TxId -> Bool
$c/= :: TxId -> TxId -> Bool
/= :: TxId -> TxId -> Bool
Eq, Eq TxId
Eq TxId =>
(TxId -> TxId -> Ordering)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> TxId)
-> (TxId -> TxId -> TxId)
-> Ord TxId
TxId -> TxId -> Bool
TxId -> TxId -> Ordering
TxId -> TxId -> TxId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TxId -> TxId -> Ordering
compare :: TxId -> TxId -> Ordering
$c< :: TxId -> TxId -> Bool
< :: TxId -> TxId -> Bool
$c<= :: TxId -> TxId -> Bool
<= :: TxId -> TxId -> Bool
$c> :: TxId -> TxId -> Bool
> :: TxId -> TxId -> Bool
$c>= :: TxId -> TxId -> Bool
>= :: TxId -> TxId -> Bool
$cmax :: TxId -> TxId -> TxId
max :: TxId -> TxId -> TxId
$cmin :: TxId -> TxId -> TxId
min :: TxId -> TxId -> TxId
Ord, (forall x. TxId -> Rep TxId x)
-> (forall x. Rep TxId x -> TxId) -> Generic TxId
forall x. Rep TxId x -> TxId
forall x. TxId -> Rep TxId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxId -> Rep TxId x
from :: forall x. TxId -> Rep TxId x
$cto :: forall x. Rep TxId x -> TxId
to :: forall x. Rep TxId x -> TxId
Generic)
deriving anyclass (TxId -> ()
(TxId -> ()) -> NFData TxId
forall a. (a -> ()) -> NFData a
$crnf :: TxId -> ()
rnf :: TxId -> ()
NFData)
deriving newtype (TxId -> TxId -> Bool
(TxId -> TxId -> Bool) -> Eq TxId
forall a. (a -> a -> Bool) -> Eq a
$c== :: TxId -> TxId -> Bool
== :: TxId -> TxId -> Bool
PlutusTx.Eq, Eq TxId
Eq TxId =>
(TxId -> TxId -> Ordering)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> Bool)
-> (TxId -> TxId -> TxId)
-> (TxId -> TxId -> TxId)
-> Ord TxId
TxId -> TxId -> Bool
TxId -> TxId -> Ordering
TxId -> TxId -> TxId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TxId -> TxId -> Ordering
compare :: TxId -> TxId -> Ordering
$c< :: TxId -> TxId -> Bool
< :: TxId -> TxId -> Bool
$c<= :: TxId -> TxId -> Bool
<= :: TxId -> TxId -> Bool
$c> :: TxId -> TxId -> Bool
> :: TxId -> TxId -> Bool
$c>= :: TxId -> TxId -> Bool
>= :: TxId -> TxId -> Bool
$cmax :: TxId -> TxId -> TxId
max :: TxId -> TxId -> TxId
$cmin :: TxId -> TxId -> TxId
min :: TxId -> TxId -> TxId
PlutusTx.Ord)
deriving
(String -> TxId
(String -> TxId) -> IsString TxId
forall a. (String -> a) -> IsString a
$cfromString :: String -> TxId
fromString :: String -> TxId
IsString
, Int -> TxId -> ShowS
[TxId] -> ShowS
TxId -> String
(Int -> TxId -> ShowS)
-> (TxId -> String) -> ([TxId] -> ShowS) -> Show TxId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxId -> ShowS
showsPrec :: Int -> TxId -> ShowS
$cshow :: TxId -> String
show :: TxId -> String
$cshowList :: [TxId] -> ShowS
showList :: [TxId] -> ShowS
Show
, (forall ann. TxId -> Doc ann)
-> (forall ann. [TxId] -> Doc ann) -> Pretty TxId
forall ann. [TxId] -> Doc ann
forall ann. TxId -> Doc ann
forall a.
(forall ann. a -> Doc ann)
-> (forall ann. [a] -> Doc ann) -> Pretty a
$cpretty :: forall ann. TxId -> Doc ann
pretty :: forall ann. TxId -> Doc ann
$cprettyList :: forall ann. [TxId] -> Doc ann
prettyList :: forall ann. [TxId] -> Doc ann
Pretty
) via LedgerBytes
data ScriptTag = Spend | Mint | Cert | Reward
deriving stock (Int -> ScriptTag -> ShowS
[ScriptTag] -> ShowS
ScriptTag -> String
(Int -> ScriptTag -> ShowS)
-> (ScriptTag -> String)
-> ([ScriptTag] -> ShowS)
-> Show ScriptTag
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ScriptTag -> ShowS
showsPrec :: Int -> ScriptTag -> ShowS
$cshow :: ScriptTag -> String
show :: ScriptTag -> String
$cshowList :: [ScriptTag] -> ShowS
showList :: [ScriptTag] -> ShowS
Show, ScriptTag -> ScriptTag -> Bool
(ScriptTag -> ScriptTag -> Bool)
-> (ScriptTag -> ScriptTag -> Bool) -> Eq ScriptTag
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ScriptTag -> ScriptTag -> Bool
== :: ScriptTag -> ScriptTag -> Bool
$c/= :: ScriptTag -> ScriptTag -> Bool
/= :: ScriptTag -> ScriptTag -> Bool
Eq, Eq ScriptTag
Eq ScriptTag =>
(ScriptTag -> ScriptTag -> Ordering)
-> (ScriptTag -> ScriptTag -> Bool)
-> (ScriptTag -> ScriptTag -> Bool)
-> (ScriptTag -> ScriptTag -> Bool)
-> (ScriptTag -> ScriptTag -> Bool)
-> (ScriptTag -> ScriptTag -> ScriptTag)
-> (ScriptTag -> ScriptTag -> ScriptTag)
-> Ord ScriptTag
ScriptTag -> ScriptTag -> Bool
ScriptTag -> ScriptTag -> Ordering
ScriptTag -> ScriptTag -> ScriptTag
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: ScriptTag -> ScriptTag -> Ordering
compare :: ScriptTag -> ScriptTag -> Ordering
$c< :: ScriptTag -> ScriptTag -> Bool
< :: ScriptTag -> ScriptTag -> Bool
$c<= :: ScriptTag -> ScriptTag -> Bool
<= :: ScriptTag -> ScriptTag -> Bool
$c> :: ScriptTag -> ScriptTag -> Bool
> :: ScriptTag -> ScriptTag -> Bool
$c>= :: ScriptTag -> ScriptTag -> Bool
>= :: ScriptTag -> ScriptTag -> Bool
$cmax :: ScriptTag -> ScriptTag -> ScriptTag
max :: ScriptTag -> ScriptTag -> ScriptTag
$cmin :: ScriptTag -> ScriptTag -> ScriptTag
min :: ScriptTag -> ScriptTag -> ScriptTag
Ord, (forall x. ScriptTag -> Rep ScriptTag x)
-> (forall x. Rep ScriptTag x -> ScriptTag) -> Generic ScriptTag
forall x. Rep ScriptTag x -> ScriptTag
forall x. ScriptTag -> Rep ScriptTag x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ScriptTag -> Rep ScriptTag x
from :: forall x. ScriptTag -> Rep ScriptTag x
$cto :: forall x. Rep ScriptTag x -> ScriptTag
to :: forall x. Rep ScriptTag x -> ScriptTag
Generic)
deriving anyclass (ScriptTag -> ()
(ScriptTag -> ()) -> NFData ScriptTag
forall a. (a -> ()) -> NFData a
$crnf :: ScriptTag -> ()
rnf :: ScriptTag -> ()
NFData)
data RedeemerPtr = RedeemerPtr ScriptTag Integer
deriving stock (Int -> RedeemerPtr -> ShowS
[RedeemerPtr] -> ShowS
RedeemerPtr -> String
(Int -> RedeemerPtr -> ShowS)
-> (RedeemerPtr -> String)
-> ([RedeemerPtr] -> ShowS)
-> Show RedeemerPtr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RedeemerPtr -> ShowS
showsPrec :: Int -> RedeemerPtr -> ShowS
$cshow :: RedeemerPtr -> String
show :: RedeemerPtr -> String
$cshowList :: [RedeemerPtr] -> ShowS
showList :: [RedeemerPtr] -> ShowS
Show, RedeemerPtr -> RedeemerPtr -> Bool
(RedeemerPtr -> RedeemerPtr -> Bool)
-> (RedeemerPtr -> RedeemerPtr -> Bool) -> Eq RedeemerPtr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RedeemerPtr -> RedeemerPtr -> Bool
== :: RedeemerPtr -> RedeemerPtr -> Bool
$c/= :: RedeemerPtr -> RedeemerPtr -> Bool
/= :: RedeemerPtr -> RedeemerPtr -> Bool
Eq, Eq RedeemerPtr
Eq RedeemerPtr =>
(RedeemerPtr -> RedeemerPtr -> Ordering)
-> (RedeemerPtr -> RedeemerPtr -> Bool)
-> (RedeemerPtr -> RedeemerPtr -> Bool)
-> (RedeemerPtr -> RedeemerPtr -> Bool)
-> (RedeemerPtr -> RedeemerPtr -> Bool)
-> (RedeemerPtr -> RedeemerPtr -> RedeemerPtr)
-> (RedeemerPtr -> RedeemerPtr -> RedeemerPtr)
-> Ord RedeemerPtr
RedeemerPtr -> RedeemerPtr -> Bool
RedeemerPtr -> RedeemerPtr -> Ordering
RedeemerPtr -> RedeemerPtr -> RedeemerPtr
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: RedeemerPtr -> RedeemerPtr -> Ordering
compare :: RedeemerPtr -> RedeemerPtr -> Ordering
$c< :: RedeemerPtr -> RedeemerPtr -> Bool
< :: RedeemerPtr -> RedeemerPtr -> Bool
$c<= :: RedeemerPtr -> RedeemerPtr -> Bool
<= :: RedeemerPtr -> RedeemerPtr -> Bool
$c> :: RedeemerPtr -> RedeemerPtr -> Bool
> :: RedeemerPtr -> RedeemerPtr -> Bool
$c>= :: RedeemerPtr -> RedeemerPtr -> Bool
>= :: RedeemerPtr -> RedeemerPtr -> Bool
$cmax :: RedeemerPtr -> RedeemerPtr -> RedeemerPtr
max :: RedeemerPtr -> RedeemerPtr -> RedeemerPtr
$cmin :: RedeemerPtr -> RedeemerPtr -> RedeemerPtr
min :: RedeemerPtr -> RedeemerPtr -> RedeemerPtr
Ord, (forall x. RedeemerPtr -> Rep RedeemerPtr x)
-> (forall x. Rep RedeemerPtr x -> RedeemerPtr)
-> Generic RedeemerPtr
forall x. Rep RedeemerPtr x -> RedeemerPtr
forall x. RedeemerPtr -> Rep RedeemerPtr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RedeemerPtr -> Rep RedeemerPtr x
from :: forall x. RedeemerPtr -> Rep RedeemerPtr x
$cto :: forall x. Rep RedeemerPtr x -> RedeemerPtr
to :: forall x. Rep RedeemerPtr x -> RedeemerPtr
Generic)
deriving anyclass (RedeemerPtr -> ()
(RedeemerPtr -> ()) -> NFData RedeemerPtr
forall a. (a -> ()) -> NFData a
$crnf :: RedeemerPtr -> ()
rnf :: RedeemerPtr -> ()
NFData)
type Redeemers = Map RedeemerPtr Redeemer
data TxOutRef = TxOutRef {
TxOutRef -> TxId
txOutRefId :: TxId,
TxOutRef -> Integer
txOutRefIdx :: Integer
}
deriving stock (Int -> TxOutRef -> ShowS
[TxOutRef] -> ShowS
TxOutRef -> String
(Int -> TxOutRef -> ShowS)
-> (TxOutRef -> String) -> ([TxOutRef] -> ShowS) -> Show TxOutRef
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxOutRef -> ShowS
showsPrec :: Int -> TxOutRef -> ShowS
$cshow :: TxOutRef -> String
show :: TxOutRef -> String
$cshowList :: [TxOutRef] -> ShowS
showList :: [TxOutRef] -> ShowS
Show, TxOutRef -> TxOutRef -> Bool
(TxOutRef -> TxOutRef -> Bool)
-> (TxOutRef -> TxOutRef -> Bool) -> Eq TxOutRef
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxOutRef -> TxOutRef -> Bool
== :: TxOutRef -> TxOutRef -> Bool
$c/= :: TxOutRef -> TxOutRef -> Bool
/= :: TxOutRef -> TxOutRef -> Bool
Eq, Eq TxOutRef
Eq TxOutRef =>
(TxOutRef -> TxOutRef -> Ordering)
-> (TxOutRef -> TxOutRef -> Bool)
-> (TxOutRef -> TxOutRef -> Bool)
-> (TxOutRef -> TxOutRef -> Bool)
-> (TxOutRef -> TxOutRef -> Bool)
-> (TxOutRef -> TxOutRef -> TxOutRef)
-> (TxOutRef -> TxOutRef -> TxOutRef)
-> Ord TxOutRef
TxOutRef -> TxOutRef -> Bool
TxOutRef -> TxOutRef -> Ordering
TxOutRef -> TxOutRef -> TxOutRef
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: TxOutRef -> TxOutRef -> Ordering
compare :: TxOutRef -> TxOutRef -> Ordering
$c< :: TxOutRef -> TxOutRef -> Bool
< :: TxOutRef -> TxOutRef -> Bool
$c<= :: TxOutRef -> TxOutRef -> Bool
<= :: TxOutRef -> TxOutRef -> Bool
$c> :: TxOutRef -> TxOutRef -> Bool
> :: TxOutRef -> TxOutRef -> Bool
$c>= :: TxOutRef -> TxOutRef -> Bool
>= :: TxOutRef -> TxOutRef -> Bool
$cmax :: TxOutRef -> TxOutRef -> TxOutRef
max :: TxOutRef -> TxOutRef -> TxOutRef
$cmin :: TxOutRef -> TxOutRef -> TxOutRef
min :: TxOutRef -> TxOutRef -> TxOutRef
Ord, (forall x. TxOutRef -> Rep TxOutRef x)
-> (forall x. Rep TxOutRef x -> TxOutRef) -> Generic TxOutRef
forall x. Rep TxOutRef x -> TxOutRef
forall x. TxOutRef -> Rep TxOutRef x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxOutRef -> Rep TxOutRef x
from :: forall x. TxOutRef -> Rep TxOutRef x
$cto :: forall x. Rep TxOutRef x -> TxOutRef
to :: forall x. Rep TxOutRef x -> TxOutRef
Generic)
deriving anyclass (TxOutRef -> ()
(TxOutRef -> ()) -> NFData TxOutRef
forall a. (a -> ()) -> NFData a
$crnf :: TxOutRef -> ()
rnf :: TxOutRef -> ()
NFData)
instance Pretty TxOutRef where
pretty :: forall ann. TxOutRef -> Doc ann
pretty TxOutRef{TxId
txOutRefId :: TxOutRef -> TxId
txOutRefId :: TxId
txOutRefId, Integer
txOutRefIdx :: TxOutRef -> Integer
txOutRefIdx :: Integer
txOutRefIdx} = TxId -> Doc ann
forall a ann. Pretty a => a -> Doc ann
forall ann. TxId -> Doc ann
pretty TxId
txOutRefId Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Doc ann
"!" Doc ann -> Doc ann -> Doc ann
forall a. Semigroup a => a -> a -> a
<> Integer -> Doc ann
forall ann. Integer -> Doc ann
forall a ann. Pretty a => a -> Doc ann
pretty Integer
txOutRefIdx
instance PlutusTx.Eq TxOutRef where
{-# INLINABLE (==) #-}
TxOutRef
l == :: TxOutRef -> TxOutRef -> Bool
== TxOutRef
r =
TxOutRef -> TxId
txOutRefId TxOutRef
l TxId -> TxId -> Bool
forall a. Eq a => a -> a -> Bool
PlutusTx.== TxOutRef -> TxId
txOutRefId TxOutRef
r
Bool -> Bool -> Bool
PlutusTx.&& TxOutRef -> Integer
txOutRefIdx TxOutRef
l Integer -> Integer -> Bool
forall a. Eq a => a -> a -> Bool
PlutusTx.== TxOutRef -> Integer
txOutRefIdx TxOutRef
r
data TxOut = TxOut {
TxOut -> Address
txOutAddress :: Address,
TxOut -> Value
txOutValue :: Value,
TxOut -> Maybe DatumHash
txOutDatumHash :: Maybe DatumHash
}
deriving stock (Int -> TxOut -> ShowS
[TxOut] -> ShowS
TxOut -> String
(Int -> TxOut -> ShowS)
-> (TxOut -> String) -> ([TxOut] -> ShowS) -> Show TxOut
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TxOut -> ShowS
showsPrec :: Int -> TxOut -> ShowS
$cshow :: TxOut -> String
show :: TxOut -> String
$cshowList :: [TxOut] -> ShowS
showList :: [TxOut] -> ShowS
Show, TxOut -> TxOut -> Bool
(TxOut -> TxOut -> Bool) -> (TxOut -> TxOut -> Bool) -> Eq TxOut
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: TxOut -> TxOut -> Bool
== :: TxOut -> TxOut -> Bool
$c/= :: TxOut -> TxOut -> Bool
/= :: TxOut -> TxOut -> Bool
Eq, (forall x. TxOut -> Rep TxOut x)
-> (forall x. Rep TxOut x -> TxOut) -> Generic TxOut
forall x. Rep TxOut x -> TxOut
forall x. TxOut -> Rep TxOut x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. TxOut -> Rep TxOut x
from :: forall x. TxOut -> Rep TxOut x
$cto :: forall x. Rep TxOut x -> TxOut
to :: forall x. Rep TxOut x -> TxOut
Generic)
instance Pretty TxOut where
pretty :: forall ann. TxOut -> Doc ann
pretty TxOut{Address
txOutAddress :: TxOut -> Address
txOutAddress :: Address
txOutAddress, Value
txOutValue :: TxOut -> Value
txOutValue :: Value
txOutValue} =
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
forall ann. Value -> Doc ann
pretty Value
txOutValue 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
forall ann. Address -> Doc ann
pretty Address
txOutAddress]
instance PlutusTx.Eq TxOut where
{-# INLINABLE (==) #-}
TxOut
l == :: TxOut -> TxOut -> Bool
== TxOut
r =
TxOut -> Address
txOutAddress TxOut
l Address -> Address -> Bool
forall a. Eq a => a -> a -> Bool
PlutusTx.== TxOut -> Address
txOutAddress TxOut
r
Bool -> Bool -> Bool
PlutusTx.&& TxOut -> Value
txOutValue TxOut
l Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
PlutusTx.== TxOut -> Value
txOutValue TxOut
r
Bool -> Bool -> Bool
PlutusTx.&& TxOut -> Maybe DatumHash
txOutDatumHash TxOut
l Maybe DatumHash -> Maybe DatumHash -> Bool
forall a. Eq a => a -> a -> Bool
PlutusTx.== TxOut -> Maybe DatumHash
txOutDatumHash TxOut
r
txOutDatum :: TxOut -> Maybe DatumHash
txOutDatum :: TxOut -> Maybe DatumHash
txOutDatum TxOut{Maybe DatumHash
txOutDatumHash :: TxOut -> Maybe DatumHash
txOutDatumHash :: Maybe DatumHash
txOutDatumHash} = Maybe DatumHash
txOutDatumHash
txOutPubKey :: TxOut -> Maybe PubKeyHash
txOutPubKey :: TxOut -> Maybe PubKeyHash
txOutPubKey TxOut{Address
txOutAddress :: TxOut -> Address
txOutAddress :: Address
txOutAddress} = Address -> Maybe PubKeyHash
toPubKeyHash Address
txOutAddress
txOutScriptHash :: TxOut -> Maybe ScriptHash
txOutScriptHash :: TxOut -> Maybe ScriptHash
txOutScriptHash TxOut{Address
txOutAddress :: TxOut -> Address
txOutAddress :: Address
txOutAddress} = Address -> Maybe ScriptHash
toScriptHash Address
txOutAddress
outAddress :: Lens' TxOut Address
outAddress :: Lens' TxOut Address
outAddress = (TxOut -> Address)
-> (TxOut -> Address -> TxOut) -> Lens' TxOut Address
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens TxOut -> Address
txOutAddress TxOut -> Address -> TxOut
s where
s :: TxOut -> Address -> TxOut
s TxOut
tx Address
a = TxOut
tx { txOutAddress = a }
outValue :: Lens' TxOut Value
outValue :: Lens' TxOut Value
outValue = (TxOut -> Value) -> (TxOut -> Value -> TxOut) -> Lens' TxOut Value
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
lens TxOut -> Value
txOutValue TxOut -> Value -> TxOut
s where
s :: TxOut -> Value -> TxOut
s TxOut
tx Value
v = TxOut
tx { txOutValue = v }
isPubKeyOut :: TxOut -> Bool
isPubKeyOut :: TxOut -> Bool
isPubKeyOut = Maybe PubKeyHash -> Bool
forall a. Maybe a -> Bool
isJust (Maybe PubKeyHash -> Bool)
-> (TxOut -> Maybe PubKeyHash) -> TxOut -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOut -> Maybe PubKeyHash
txOutPubKey
isPayToScriptOut :: TxOut -> Bool
isPayToScriptOut :: TxOut -> Bool
isPayToScriptOut = Maybe ScriptHash -> Bool
forall a. Maybe a -> Bool
isJust (Maybe ScriptHash -> Bool)
-> (TxOut -> Maybe ScriptHash) -> TxOut -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. TxOut -> Maybe ScriptHash
txOutScriptHash
pubKeyHashTxOut :: Value -> PubKeyHash -> TxOut
pubKeyHashTxOut :: Value -> PubKeyHash -> TxOut
pubKeyHashTxOut Value
v PubKeyHash
pkh = Address -> Value -> Maybe DatumHash -> TxOut
TxOut (PubKeyHash -> Address
pubKeyHashAddress PubKeyHash
pkh) Value
v Maybe DatumHash
forall a. Maybe a
Nothing
PlutusTx.makeLift ''TxId
PlutusTx.makeIsDataIndexed ''TxId [('TxId,0)]
PlutusTx.makeIsDataIndexed ''TxOut [('TxOut,0)]
PlutusTx.makeLift ''TxOut
PlutusTx.makeIsDataIndexed ''TxOutRef [('TxOutRef,0)]
PlutusTx.makeLift ''TxOutRef