Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PLT-7586 [DO NOT MERGE] Marlowe semantics validator with `PlutusTx.As…
…Data` (#10) PLT-7585 Ported `PlutusTx.AsData` validator from IntersectMBO/plutus@107c9a6.
- Loading branch information
Showing
6 changed files
with
1,311 additions
and
26 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
51 changes: 51 additions & 0 deletions
51
marlowe-plutus/src/Language/Marlowe/Plutus/Alt/ScriptTypes.hs
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,51 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DerivingStrategies #-} | ||
{-# LANGUAGE ImportQualifiedPost #-} | ||
{-# LANGUAGE MultiParamTypeClasses #-} | ||
{-# LANGUAGE TemplateHaskell #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
{-# LANGUAGE NoImplicitPrelude #-} | ||
|
||
-- | Marlowe validators. | ||
-- | ||
-- Module : $Headers | ||
-- License : Apache 2.0 | ||
-- | ||
-- Stability : Experimental | ||
-- Portability : Portable | ||
module Language.Marlowe.Plutus.Alt.ScriptTypes ( | ||
-- * Types | ||
MarloweInput, | ||
MarloweTxInput (..), | ||
|
||
-- * Utilities | ||
marloweTxInputsFromInputs, | ||
) where | ||
|
||
import GHC.Generics (Generic) | ||
import Language.Marlowe.Plutus.Alt.Semantics.Types as Semantics | ||
import PlutusTx (makeIsDataIndexed, makeLift) | ||
import PlutusTx.Prelude as PlutusTxPrelude hiding (traceError, traceIfFalse) | ||
import Prelude qualified as Haskell | ||
|
||
-- | Input to a Marlowe transaction. | ||
type MarloweInput = [MarloweTxInput] | ||
|
||
-- | A single input applied in the Marlowe semantics validator. | ||
data MarloweTxInput | ||
= Input InputContent | ||
| MerkleizedTxInput InputContent BuiltinByteString | ||
deriving stock (Haskell.Show, Haskell.Eq, Generic) | ||
|
||
-- | Convert semantics input to transaction input. | ||
marloweTxInputFromInput :: Input -> MarloweTxInput | ||
marloweTxInputFromInput (NormalInput i) = Input i | ||
marloweTxInputFromInput (MerkleizedInput i h _) = MerkleizedTxInput i h | ||
|
||
-- | Convert semantics inputs to transaction inputs. | ||
marloweTxInputsFromInputs :: [Input] -> [MarloweTxInput] | ||
marloweTxInputsFromInputs = fmap marloweTxInputFromInput | ||
|
||
-- Lifting data types to Plutus Core | ||
makeLift ''MarloweTxInput | ||
makeIsDataIndexed ''MarloweTxInput [('Input, 0), ('MerkleizedTxInput, 1)] |
Oops, something went wrong.