{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fplugin PlutusTx.Plugin #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:defer-errors #-}
{-# OPTIONS_GHC -fplugin-opt PlutusTx.Plugin:target-version=1.1.0 #-}
module Hydra.Contract.Dummy where
import Hydra.Prelude
import Hydra.Cardano.Api (PlutusScript, pattern PlutusScriptSerialised)
import PlutusLedgerApi.V3 (ScriptContext (..), ScriptInfo (..), serialiseCompiledCode, unsafeFromBuiltinData)
import PlutusTx (compile)
import PlutusTx.Prelude (check)
dummyValidatorScript :: PlutusScript
dummyValidatorScript :: PlutusScript
dummyValidatorScript =
ShortByteString -> PlutusScript
PlutusScriptSerialised (ShortByteString -> PlutusScript)
-> ShortByteString -> PlutusScript
forall a b. (a -> b) -> a -> b
$
CompiledCode (BuiltinData -> BuiltinUnit) -> ShortByteString
forall a. CompiledCode a -> ShortByteString
serialiseCompiledCode
$$( PlutusTx.compile
[||
\ctx ->
check $ case unsafeFromBuiltinData ctx of
ScriptContext{scriptContextScriptInfo = SpendingScript{}} -> True
_ -> False
||]
)
dummyMintingScript :: PlutusScript
dummyMintingScript :: PlutusScript
dummyMintingScript =
ShortByteString -> PlutusScript
PlutusScriptSerialised (ShortByteString -> PlutusScript)
-> ShortByteString -> PlutusScript
forall a b. (a -> b) -> a -> b
$
CompiledCode (BuiltinData -> BuiltinUnit) -> ShortByteString
forall a. CompiledCode a -> ShortByteString
serialiseCompiledCode
$$( PlutusTx.compile
[||
\ctx ->
check $ case unsafeFromBuiltinData ctx of
ScriptContext{scriptContextScriptInfo = MintingScript{}} -> True
_ -> False
||]
)
dummyRewardingScript :: PlutusScript
dummyRewardingScript :: PlutusScript
dummyRewardingScript =
ShortByteString -> PlutusScript
PlutusScriptSerialised (ShortByteString -> PlutusScript)
-> ShortByteString -> PlutusScript
forall a b. (a -> b) -> a -> b
$
CompiledCode (BuiltinData -> BuiltinUnit) -> ShortByteString
forall a. CompiledCode a -> ShortByteString
serialiseCompiledCode
$$( PlutusTx.compile
[||
\ctx ->
check $ case unsafeFromBuiltinData ctx of
ScriptContext{scriptContextScriptInfo = CertifyingScript{}} -> True
ScriptContext{scriptContextScriptInfo = RewardingScript{}} -> True
_ -> False
||]
)