module Plutus.Script.Utils.V2.Tx
( scriptTxOut
) where
import Plutus.Script.Utils.V2.Address (mkValidatorAddress)
import Plutus.Script.Utils.V2.Scripts (scriptHash)
import Plutus.V2.Ledger.Api (OutputDatum, TxOut (TxOut), Validator, Value, unValidatorScript)
type HasReferenceScript = Bool
scriptTxOut :: Validator -> Value -> OutputDatum -> HasReferenceScript -> TxOut
scriptTxOut :: Validator -> Value -> OutputDatum -> HasReferenceScript -> TxOut
scriptTxOut Validator
validator Value
val OutputDatum
datum HasReferenceScript
True =
Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
TxOut (Validator -> Address
mkValidatorAddress Validator
validator) Value
val OutputDatum
datum (ScriptHash -> Maybe ScriptHash
forall a. a -> Maybe a
Just (ScriptHash -> Maybe ScriptHash) -> ScriptHash -> Maybe ScriptHash
forall a b. (a -> b) -> a -> b
$ Script -> ScriptHash
scriptHash (Script -> ScriptHash) -> Script -> ScriptHash
forall a b. (a -> b) -> a -> b
$ Validator -> Script
unValidatorScript Validator
validator)
scriptTxOut Validator
validator Value
val OutputDatum
datum HasReferenceScript
False =
Address -> Value -> OutputDatum -> Maybe ScriptHash -> TxOut
TxOut (Validator -> Address
mkValidatorAddress Validator
validator) Value
val OutputDatum
datum Maybe ScriptHash
forall a. Maybe a
Nothing