{-# OPTIONS_GHC -Wno-orphans #-}
module Hydra.Cluster.Fixture where
import Hydra.Prelude
import Hydra.Cardano.Api (NetworkId)
import Hydra.Cardano.Api qualified as Api
import Hydra.Tx (Party, deriveParty)
import Hydra.Tx.ContestationPeriod (ContestationPeriod (..))
import Hydra.Tx.Crypto (HydraKey, SigningKey, VerificationKey, generateSigningKey, getVerificationKey)
alice, bob, carol :: Party
alice :: Party
alice = SigningKey HydraKey -> Party
deriveParty SigningKey HydraKey
aliceSk
bob :: Party
bob = SigningKey HydraKey -> Party
deriveParty SigningKey HydraKey
bobSk
carol :: Party
carol = SigningKey HydraKey -> Party
deriveParty SigningKey HydraKey
carolSk
aliceSk, bobSk, carolSk :: SigningKey HydraKey
aliceSk :: SigningKey HydraKey
aliceSk = ByteString -> SigningKey HydraKey
generateSigningKey ByteString
"alice"
bobSk :: SigningKey HydraKey
bobSk = ByteString -> SigningKey HydraKey
generateSigningKey ByteString
"bob"
carolSk :: SigningKey HydraKey
carolSk = ByteString -> SigningKey HydraKey
generateSigningKey ByteString
"carol"
aliceVk, bobVk, carolVk :: VerificationKey HydraKey
aliceVk :: VerificationKey HydraKey
aliceVk = SigningKey HydraKey -> VerificationKey HydraKey
forall keyrole.
(Key keyrole, HasTypeProxy keyrole) =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey SigningKey HydraKey
aliceSk
bobVk :: VerificationKey HydraKey
bobVk = SigningKey HydraKey -> VerificationKey HydraKey
forall keyrole.
(Key keyrole, HasTypeProxy keyrole) =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey SigningKey HydraKey
bobSk
carolVk :: VerificationKey HydraKey
carolVk = SigningKey HydraKey -> VerificationKey HydraKey
forall keyrole.
(Key keyrole, HasTypeProxy keyrole) =>
SigningKey keyrole -> VerificationKey keyrole
getVerificationKey SigningKey HydraKey
carolSk
cperiod :: ContestationPeriod
cperiod :: ContestationPeriod
cperiod = Natural -> ContestationPeriod
UnsafeContestationPeriod Natural
10
defaultNetworkId :: NetworkId
defaultNetworkId :: NetworkId
defaultNetworkId = NetworkMagic -> NetworkId
Api.Testnet (Word32 -> NetworkMagic
Api.NetworkMagic Word32
42)
availableInitialFunds :: Num a => a
availableInitialFunds :: forall a. Num a => a
availableInitialFunds = a
900_000_000_000
data Actor
= Alice
| AliceFunds
| Bob
| BobFunds
| Carol
| CarolFunds
| Faucet
deriving stock (Actor -> Actor -> Bool
(Actor -> Actor -> Bool) -> (Actor -> Actor -> Bool) -> Eq Actor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Actor -> Actor -> Bool
== :: Actor -> Actor -> Bool
$c/= :: Actor -> Actor -> Bool
/= :: Actor -> Actor -> Bool
Eq, Int -> Actor -> ShowS
[Actor] -> ShowS
Actor -> String
(Int -> Actor -> ShowS)
-> (Actor -> String) -> ([Actor] -> ShowS) -> Show Actor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Actor -> ShowS
showsPrec :: Int -> Actor -> ShowS
$cshow :: Actor -> String
show :: Actor -> String
$cshowList :: [Actor] -> ShowS
showList :: [Actor] -> ShowS
Show)
actorName :: Actor -> String
actorName :: Actor -> String
actorName = \case
Actor
Alice -> String
"alice"
Actor
AliceFunds -> String
"alice-funds"
Actor
Bob -> String
"bob"
Actor
BobFunds -> String
"bob-funds"
Actor
Carol -> String
"carol"
Actor
CarolFunds -> String
"carol-funds"
Actor
Faucet -> String
"faucet"
fundsOf :: Actor -> Actor
fundsOf :: Actor -> Actor
fundsOf = \case
Actor
Alice -> Actor
AliceFunds
Actor
AliceFunds -> Actor
AliceFunds
Actor
Bob -> Actor
BobFunds
Actor
BobFunds -> Actor
BobFunds
Actor
Carol -> Actor
CarolFunds
Actor
CarolFunds -> Actor
CarolFunds
Actor
Faucet -> Actor
Faucet
data KnownNetwork
= Preview
| Preproduction
| Mainnet
| Sanchonet
deriving stock ((forall x. KnownNetwork -> Rep KnownNetwork x)
-> (forall x. Rep KnownNetwork x -> KnownNetwork)
-> Generic KnownNetwork
forall x. Rep KnownNetwork x -> KnownNetwork
forall x. KnownNetwork -> Rep KnownNetwork x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. KnownNetwork -> Rep KnownNetwork x
from :: forall x. KnownNetwork -> Rep KnownNetwork x
$cto :: forall x. Rep KnownNetwork x -> KnownNetwork
to :: forall x. Rep KnownNetwork x -> KnownNetwork
Generic, Int -> KnownNetwork -> ShowS
[KnownNetwork] -> ShowS
KnownNetwork -> String
(Int -> KnownNetwork -> ShowS)
-> (KnownNetwork -> String)
-> ([KnownNetwork] -> ShowS)
-> Show KnownNetwork
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> KnownNetwork -> ShowS
showsPrec :: Int -> KnownNetwork -> ShowS
$cshow :: KnownNetwork -> String
show :: KnownNetwork -> String
$cshowList :: [KnownNetwork] -> ShowS
showList :: [KnownNetwork] -> ShowS
Show, KnownNetwork -> KnownNetwork -> Bool
(KnownNetwork -> KnownNetwork -> Bool)
-> (KnownNetwork -> KnownNetwork -> Bool) -> Eq KnownNetwork
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: KnownNetwork -> KnownNetwork -> Bool
== :: KnownNetwork -> KnownNetwork -> Bool
$c/= :: KnownNetwork -> KnownNetwork -> Bool
/= :: KnownNetwork -> KnownNetwork -> Bool
Eq, Int -> KnownNetwork
KnownNetwork -> Int
KnownNetwork -> [KnownNetwork]
KnownNetwork -> KnownNetwork
KnownNetwork -> KnownNetwork -> [KnownNetwork]
KnownNetwork -> KnownNetwork -> KnownNetwork -> [KnownNetwork]
(KnownNetwork -> KnownNetwork)
-> (KnownNetwork -> KnownNetwork)
-> (Int -> KnownNetwork)
-> (KnownNetwork -> Int)
-> (KnownNetwork -> [KnownNetwork])
-> (KnownNetwork -> KnownNetwork -> [KnownNetwork])
-> (KnownNetwork -> KnownNetwork -> [KnownNetwork])
-> (KnownNetwork -> KnownNetwork -> KnownNetwork -> [KnownNetwork])
-> Enum KnownNetwork
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: KnownNetwork -> KnownNetwork
succ :: KnownNetwork -> KnownNetwork
$cpred :: KnownNetwork -> KnownNetwork
pred :: KnownNetwork -> KnownNetwork
$ctoEnum :: Int -> KnownNetwork
toEnum :: Int -> KnownNetwork
$cfromEnum :: KnownNetwork -> Int
fromEnum :: KnownNetwork -> Int
$cenumFrom :: KnownNetwork -> [KnownNetwork]
enumFrom :: KnownNetwork -> [KnownNetwork]
$cenumFromThen :: KnownNetwork -> KnownNetwork -> [KnownNetwork]
enumFromThen :: KnownNetwork -> KnownNetwork -> [KnownNetwork]
$cenumFromTo :: KnownNetwork -> KnownNetwork -> [KnownNetwork]
enumFromTo :: KnownNetwork -> KnownNetwork -> [KnownNetwork]
$cenumFromThenTo :: KnownNetwork -> KnownNetwork -> KnownNetwork -> [KnownNetwork]
enumFromThenTo :: KnownNetwork -> KnownNetwork -> KnownNetwork -> [KnownNetwork]
Enum, KnownNetwork
KnownNetwork -> KnownNetwork -> Bounded KnownNetwork
forall a. a -> a -> Bounded a
$cminBound :: KnownNetwork
minBound :: KnownNetwork
$cmaxBound :: KnownNetwork
maxBound :: KnownNetwork
Bounded)
deriving anyclass ([KnownNetwork] -> Value
[KnownNetwork] -> Encoding
KnownNetwork -> Bool
KnownNetwork -> Value
KnownNetwork -> Encoding
(KnownNetwork -> Value)
-> (KnownNetwork -> Encoding)
-> ([KnownNetwork] -> Value)
-> ([KnownNetwork] -> Encoding)
-> (KnownNetwork -> Bool)
-> ToJSON KnownNetwork
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> (a -> Bool)
-> ToJSON a
$ctoJSON :: KnownNetwork -> Value
toJSON :: KnownNetwork -> Value
$ctoEncoding :: KnownNetwork -> Encoding
toEncoding :: KnownNetwork -> Encoding
$ctoJSONList :: [KnownNetwork] -> Value
toJSONList :: [KnownNetwork] -> Value
$ctoEncodingList :: [KnownNetwork] -> Encoding
toEncodingList :: [KnownNetwork] -> Encoding
$comitField :: KnownNetwork -> Bool
omitField :: KnownNetwork -> Bool
ToJSON, Maybe KnownNetwork
Value -> Parser [KnownNetwork]
Value -> Parser KnownNetwork
(Value -> Parser KnownNetwork)
-> (Value -> Parser [KnownNetwork])
-> Maybe KnownNetwork
-> FromJSON KnownNetwork
forall a.
(Value -> Parser a)
-> (Value -> Parser [a]) -> Maybe a -> FromJSON a
$cparseJSON :: Value -> Parser KnownNetwork
parseJSON :: Value -> Parser KnownNetwork
$cparseJSONList :: Value -> Parser [KnownNetwork]
parseJSONList :: Value -> Parser [KnownNetwork]
$comittedField :: Maybe KnownNetwork
omittedField :: Maybe KnownNetwork
FromJSON)
toNetworkId :: KnownNetwork -> NetworkId
toNetworkId :: KnownNetwork -> NetworkId
toNetworkId = \case
KnownNetwork
Mainnet -> NetworkId
Api.Mainnet
KnownNetwork
Preproduction -> NetworkMagic -> NetworkId
Api.Testnet (Word32 -> NetworkMagic
Api.NetworkMagic Word32
1)
KnownNetwork
Preview -> NetworkMagic -> NetworkId
Api.Testnet (Word32 -> NetworkMagic
Api.NetworkMagic Word32
2)
KnownNetwork
Sanchonet -> NetworkMagic -> NetworkId
Api.Testnet (Word32 -> NetworkMagic
Api.NetworkMagic Word32
4)