module Hydra.Tx.HeadParameters where

import Hydra.Prelude

import Hydra.Tx.ContestationPeriod (ContestationPeriod)
import Hydra.Tx.DepositPeriod (DepositPeriod)
import Hydra.Tx.Party (Party (..))

-- | Contains the head's parameters as established in the initial transaction.
data HeadParameters = HeadParameters
  { HeadParameters -> ContestationPeriod
contestationPeriod :: ContestationPeriod
  , HeadParameters -> DepositPeriod
depositPeriod :: DepositPeriod
  , HeadParameters -> [Party]
parties :: [Party] -- NOTE(SN): The order of this list is important for leader selection.
  }
  deriving stock (HeadParameters -> HeadParameters -> Bool
(HeadParameters -> HeadParameters -> Bool)
-> (HeadParameters -> HeadParameters -> Bool) -> Eq HeadParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: HeadParameters -> HeadParameters -> Bool
== :: HeadParameters -> HeadParameters -> Bool
$c/= :: HeadParameters -> HeadParameters -> Bool
/= :: HeadParameters -> HeadParameters -> Bool
Eq, Int -> HeadParameters -> ShowS
[HeadParameters] -> ShowS
HeadParameters -> String
(Int -> HeadParameters -> ShowS)
-> (HeadParameters -> String)
-> ([HeadParameters] -> ShowS)
-> Show HeadParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> HeadParameters -> ShowS
showsPrec :: Int -> HeadParameters -> ShowS
$cshow :: HeadParameters -> String
show :: HeadParameters -> String
$cshowList :: [HeadParameters] -> ShowS
showList :: [HeadParameters] -> ShowS
Show, (forall x. HeadParameters -> Rep HeadParameters x)
-> (forall x. Rep HeadParameters x -> HeadParameters)
-> Generic HeadParameters
forall x. Rep HeadParameters x -> HeadParameters
forall x. HeadParameters -> Rep HeadParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. HeadParameters -> Rep HeadParameters x
from :: forall x. HeadParameters -> Rep HeadParameters x
$cto :: forall x. Rep HeadParameters x -> HeadParameters
to :: forall x. Rep HeadParameters x -> HeadParameters
Generic)
  deriving anyclass ([HeadParameters] -> Value
[HeadParameters] -> Encoding
HeadParameters -> Bool
HeadParameters -> Value
HeadParameters -> Encoding
(HeadParameters -> Value)
-> (HeadParameters -> Encoding)
-> ([HeadParameters] -> Value)
-> ([HeadParameters] -> Encoding)
-> (HeadParameters -> Bool)
-> ToJSON HeadParameters
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: HeadParameters -> Value
toJSON :: HeadParameters -> Value
$ctoEncoding :: HeadParameters -> Encoding
toEncoding :: HeadParameters -> Encoding
$ctoJSONList :: [HeadParameters] -> Value
toJSONList :: [HeadParameters] -> Value
$ctoEncodingList :: [HeadParameters] -> Encoding
toEncodingList :: [HeadParameters] -> Encoding
$comitField :: HeadParameters -> Bool
omitField :: HeadParameters -> Bool
ToJSON, Maybe HeadParameters
Value -> Parser [HeadParameters]
Value -> Parser HeadParameters
(Value -> Parser HeadParameters)
-> (Value -> Parser [HeadParameters])
-> Maybe HeadParameters
-> FromJSON HeadParameters
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser HeadParameters
parseJSON :: Value -> Parser HeadParameters
$cparseJSONList :: Value -> Parser [HeadParameters]
parseJSONList :: Value -> Parser [HeadParameters]
$comittedField :: Maybe HeadParameters
omittedField :: Maybe HeadParameters
FromJSON)

instance ToCBOR HeadParameters where
  toCBOR :: HeadParameters -> Encoding
toCBOR = HeadParameters -> Encoding
forall a. (Generic a, GToCBOR (Rep a)) => a -> Encoding
genericToCBOR

instance FromCBOR HeadParameters where
  fromCBOR :: forall s. Decoder s HeadParameters
fromCBOR = Decoder s HeadParameters
forall a s. (Generic a, GFromCBOR (Rep a)) => Decoder s a
genericFromCBOR