module PlutusLedgerApi.Test.Scripts
    (
    uplcToScriptForEvaluation
    -- * Example scripts
    , unitRedeemer
    , unitDatum
    ) where

import PlutusLedgerApi.Common
import PlutusLedgerApi.V1.Scripts
import UntypedPlutusCore qualified as UPLC

uplcToScriptForEvaluation ::
  PlutusLedgerLanguage ->
  MajorProtocolVersion ->
  UPLC.Program UPLC.DeBruijn UPLC.DefaultUni UPLC.DefaultFun () ->
  Either ScriptDecodeError ScriptForEvaluation
uplcToScriptForEvaluation :: PlutusLedgerLanguage
-> MajorProtocolVersion
-> Program DeBruijn DefaultUni DefaultFun ()
-> Either ScriptDecodeError ScriptForEvaluation
uplcToScriptForEvaluation PlutusLedgerLanguage
ll MajorProtocolVersion
pv = PlutusLedgerLanguage
-> MajorProtocolVersion
-> SerialisedScript
-> Either ScriptDecodeError ScriptForEvaluation
forall (m :: * -> *).
MonadError ScriptDecodeError m =>
PlutusLedgerLanguage
-> MajorProtocolVersion
-> SerialisedScript
-> m ScriptForEvaluation
deserialiseScript PlutusLedgerLanguage
ll MajorProtocolVersion
pv (SerialisedScript -> Either ScriptDecodeError ScriptForEvaluation)
-> (Program DeBruijn DefaultUni DefaultFun () -> SerialisedScript)
-> Program DeBruijn DefaultUni DefaultFun ()
-> Either ScriptDecodeError ScriptForEvaluation
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Program DeBruijn DefaultUni DefaultFun () -> SerialisedScript
serialiseUPLC

-- | @()@ as a datum.
unitDatum :: Datum
unitDatum :: Datum
unitDatum = BuiltinData -> Datum
Datum (BuiltinData -> Datum) -> BuiltinData -> Datum
forall a b. (a -> b) -> a -> b
$ () -> BuiltinData
forall a. ToData a => a -> BuiltinData
toBuiltinData ()

-- | @()@ as a redeemer.
unitRedeemer :: Redeemer
unitRedeemer :: Redeemer
unitRedeemer = BuiltinData -> Redeemer
Redeemer (BuiltinData -> Redeemer) -> BuiltinData -> Redeemer
forall a b. (a -> b) -> a -> b
$ () -> BuiltinData
forall a. ToData a => a -> BuiltinData
toBuiltinData ()