diff --git a/hydra-plutus/src/Hydra/Contract/Head.hs b/hydra-plutus/src/Hydra/Contract/Head.hs index 57dd6876f9e..bb0599b7cb7 100644 --- a/hydra-plutus/src/Hydra/Contract/Head.hs +++ b/hydra-plutus/src/Hydra/Contract/Head.hs @@ -15,7 +15,7 @@ import Hydra.Cardano.Api (PlutusScriptVersion (PlutusScriptV2)) import Hydra.Contract.Commit (Commit (..)) import Hydra.Contract.Commit qualified as Commit import Hydra.Contract.HeadError (HeadError (..), errorCode) -import Hydra.Contract.HeadState (CloseRedeemer (..), ClosedDatum (..), ContestRedeemer (..), DecrementRedeemer (..), Hash, Input (..), OpenDatum (..), Signature, SnapshotNumber, SnapshotVersion, State (..)) +import Hydra.Contract.HeadState (CloseRedeemer (..), ClosedDatum (..), ContestRedeemer (..), DecrementRedeemer (..), Hash, Input (..), OpenDatum (..), Signature, SnapshotNumber, SnapshotVersion, State (..), IncrementRedeemer) import Hydra.Contract.Util (hasST, mustBurnAllHeadTokens, mustNotMintOrBurn, (===)) import Hydra.Data.ContestationPeriod (ContestationPeriod, addContestationPeriod, milliseconds) import Hydra.Data.Party (Party (vkey)) @@ -72,6 +72,8 @@ headValidator oldState input ctx = checkCollectCom ctx (contestationPeriod, parties, headId) (Initial{parties, headId}, Abort) -> checkAbort ctx headId parties + (Open openDatum, Increment redeemer) -> + checkIncrement ctx openDatum redeemer (Open openDatum, Decrement redeemer) -> checkDecrement ctx openDatum redeemer (Open openDatum, Close redeemer) -> @@ -221,6 +223,16 @@ commitDatum input = do Nothing -> [] {-# INLINEABLE commitDatum #-} +-- | Verify a increment transaction. +checkIncrement :: + ScriptContext -> + -- | Open state before the decrement + OpenDatum -> + IncrementRedeemer -> + Bool +checkIncrement ctx openBefore redeemer = False +{-# INLINEABLE checkIncrement #-} + -- | Verify a decrement transaction. checkDecrement :: ScriptContext -> diff --git a/hydra-plutus/src/Hydra/Contract/HeadState.hs b/hydra-plutus/src/Hydra/Contract/HeadState.hs index ffc3682d69b..b29b8a74895 100644 --- a/hydra-plutus/src/Hydra/Contract/HeadState.hs +++ b/hydra-plutus/src/Hydra/Contract/HeadState.hs @@ -115,6 +115,12 @@ data ContestRedeemer PlutusTx.unstableMakeIsData ''ContestRedeemer +-- | Sub-type for increment transition +data IncrementRedeemer = IncrementRedeemer + deriving stock (Show, Generic) + +PlutusTx.unstableMakeIsData ''IncrementRedeemer + -- | Sub-type for decrement transition with auxiliary data as needed. data DecrementRedeemer = DecrementRedeemer { signature :: [Signature] @@ -130,6 +136,7 @@ PlutusTx.unstableMakeIsData ''DecrementRedeemer data Input = CollectCom + | Increment IncrementRedeemer | Decrement DecrementRedeemer | Close CloseRedeemer | Contest ContestRedeemer