Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |