Skip to content

Commit

Permalink
Implement dummy Commit contract.
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Sep 23, 2021
1 parent 77e9a6c commit 32a4f8d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
1 change: 1 addition & 0 deletions hydra-plutus/hydra-plutus.cabal
Expand Up @@ -71,6 +71,7 @@ common project-config
library
import: project-config
exposed-modules:
Hydra.Contract.Commit
Hydra.Contract.Head
Hydra.Contract.Initial
Hydra.Data.ContestationPeriod
Expand Down
43 changes: 43 additions & 0 deletions hydra-plutus/src/Hydra/Contract/Commit.hs
@@ -0,0 +1,43 @@
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -fno-specialize #-}

-- | Contract for Hydra controlling the redemption of commits from participants.
module Hydra.Contract.Commit where

import Ledger hiding (validatorHash)
import PlutusTx.Prelude

import Ledger.Typed.Scripts (TypedValidator, ValidatorType, ValidatorTypes (..))
import qualified Ledger.Typed.Scripts as Scripts
import PlutusTx (CompiledCode)
import qualified PlutusTx

data Commit

instance Scripts.ValidatorTypes Commit where
type DatumType Commit = TxOut
type RedeemerType Commit = ()

validator ::
TxOut ->
() ->
ScriptContext ->
Bool
validator _commit () _ctx =
True

compiledValidator :: CompiledCode (ValidatorType Commit)
compiledValidator = $$(PlutusTx.compile [||validator||])

{- ORMOLU_DISABLE -}
typedValidator :: TypedValidator Commit
typedValidator = Scripts.mkTypedValidator @Commit
compiledValidator
$$(PlutusTx.compile [|| wrap ||])
where
wrap = Scripts.wrapValidator @(DatumType Commit) @(RedeemerType Commit)
{- ORMOLU_ENABLE -}

validatorHash :: ValidatorHash
validatorHash = Scripts.validatorHash typedValidator

0 comments on commit 32a4f8d

Please sign in to comment.