-
Notifications
You must be signed in to change notification settings - Fork 86
/
HeadState.hs
66 lines (56 loc) · 1.54 KB
/
HeadState.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE TemplateHaskell #-}
{-# OPTIONS_GHC -fno-specialize #-}
module Hydra.Contract.HeadState where
import PlutusTx.Prelude
import GHC.Generics (Generic)
import Hydra.Data.ContestationPeriod (ContestationPeriod)
import Hydra.Data.Party (Party)
import PlutusLedgerApi.V2 (CurrencySymbol, POSIXTime, PubKeyHash, TxOutRef)
import PlutusTx qualified
import Text.Show (Show)
type SnapshotNumber = Integer
type Hash = BuiltinByteString
type Signature = BuiltinByteString
data State
= Initial
{ contestationPeriod :: ContestationPeriod
, parties :: [Party]
, headId :: CurrencySymbol
, seed :: TxOutRef
}
| Open
{ contestationPeriod :: ContestationPeriod
, parties :: [Party]
, utxoHash :: Hash
, headId :: CurrencySymbol
, snapshotNumber :: SnapshotNumber
}
| Closed
{ parties :: [Party]
, snapshotNumber :: SnapshotNumber
, utxoHash :: Hash
, utxoToDecommitHash :: Hash
, contestationDeadline :: POSIXTime
, contestationPeriod :: ContestationPeriod
, headId :: CurrencySymbol
, contesters :: [PubKeyHash]
}
| Final
deriving stock (Generic, Show)
PlutusTx.unstableMakeIsData ''State
data Input
= CollectCom
| Decrement
{ signature :: [Signature]
}
| Close
{ signature :: [Signature]
}
| Contest
{ signature :: [Signature]
}
| Abort
| Fanout {numberOfFanoutOutputs :: Integer}
deriving stock (Generic, Show)
PlutusTx.unstableMakeIsData ''Input