{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE UndecidableInstances #-}
module Hydra.HeadLogic.Outcome where
import Hydra.Prelude
import Hydra.API.ServerOutput (ClientMessage, DecommitInvalidReason)
import Hydra.Chain (PostChainTx)
import Hydra.Chain.ChainState (ChainSlot, ChainStateType, IsChainState)
import Hydra.HeadLogic.Error (LogicError)
import Hydra.HeadLogic.State (HeadState)
import Hydra.Ledger (ValidationError)
import Hydra.Network (Host, ProtocolVersion)
import Hydra.Network.Message (Message)
import Hydra.Tx (
HeadId,
HeadParameters,
HeadSeed,
IsTx,
Party,
Snapshot,
SnapshotNumber,
SnapshotVersion,
TxIdType,
UTxOType,
mkHeadParameters,
)
import Hydra.Tx.ContestationPeriod (ContestationPeriod)
import Hydra.Tx.Crypto (MultiSignature, Signature)
import Hydra.Tx.Environment (Environment (..))
import Hydra.Tx.IsTx (ArbitraryIsTx)
import Hydra.Tx.OnChainId (OnChainId)
import Test.QuickCheck (oneof)
import Test.QuickCheck.Arbitrary.ADT (ToADTArbitrary)
data Effect tx
=
ClientEffect {forall tx. Effect tx -> ClientMessage tx
clientMessage :: ClientMessage tx}
|
NetworkEffect {forall tx. Effect tx -> Message tx
message :: Message tx}
|
OnChainEffect {forall tx. Effect tx -> PostChainTx tx
postChainTx :: PostChainTx tx}
deriving stock ((forall x. Effect tx -> Rep (Effect tx) x)
-> (forall x. Rep (Effect tx) x -> Effect tx)
-> Generic (Effect tx)
forall x. Rep (Effect tx) x -> Effect tx
forall x. Effect tx -> Rep (Effect tx) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall tx x. Rep (Effect tx) x -> Effect tx
forall tx x. Effect tx -> Rep (Effect tx) x
$cfrom :: forall tx x. Effect tx -> Rep (Effect tx) x
from :: forall x. Effect tx -> Rep (Effect tx) x
$cto :: forall tx x. Rep (Effect tx) x -> Effect tx
to :: forall x. Rep (Effect tx) x -> Effect tx
Generic)
deriving stock instance IsChainState tx => Eq (Effect tx)
deriving stock instance IsChainState tx => Show (Effect tx)
deriving anyclass instance IsChainState tx => ToJSON (Effect tx)
instance (ArbitraryIsTx tx, IsChainState tx) => Arbitrary (Effect tx) where
arbitrary :: Gen (Effect tx)
arbitrary = Gen (Effect tx)
forall a.
(Generic a, GA UnsizedOpts (Rep a),
UniformWeight (Weights_ (Rep a))) =>
Gen a
genericArbitrary
data StateChanged tx
= NetworkConnected
| NetworkDisconnected
| PeerConnected {forall tx. StateChanged tx -> Host
peer :: Host}
| PeerDisconnected {peer :: Host}
| NetworkVersionMismatch
{ forall tx. StateChanged tx -> ProtocolVersion
ourVersion :: ProtocolVersion
, forall tx. StateChanged tx -> Maybe ProtocolVersion
theirVersion :: Maybe ProtocolVersion
}
| HeadInitialized
{ forall tx. StateChanged tx -> HeadParameters
parameters :: HeadParameters
, forall tx. StateChanged tx -> ChainStateType tx
chainState :: ChainStateType tx
, forall tx. StateChanged tx -> HeadId
headId :: HeadId
, forall tx. StateChanged tx -> HeadSeed
headSeed :: HeadSeed
, forall tx. StateChanged tx -> [Party]
parties :: [Party]
}
| CommittedUTxO
{ headId :: HeadId
, forall tx. StateChanged tx -> Party
party :: Party
, forall tx. StateChanged tx -> UTxOType tx
committedUTxO :: UTxOType tx
, chainState :: ChainStateType tx
}
| HeadAborted {headId :: HeadId, forall tx. StateChanged tx -> UTxOType tx
utxo :: UTxOType tx, chainState :: ChainStateType tx}
| HeadOpened {headId :: HeadId, chainState :: ChainStateType tx, forall tx. StateChanged tx -> UTxOType tx
initialUTxO :: UTxOType tx}
| TransactionReceived {forall tx. StateChanged tx -> tx
tx :: tx}
| TransactionAppliedToLocalUTxO
{ headId :: HeadId
, tx :: tx
, forall tx. StateChanged tx -> UTxOType tx
newLocalUTxO :: UTxOType tx
}
| SnapshotRequestDecided {forall tx. StateChanged tx -> SnapshotNumber
snapshotNumber :: SnapshotNumber}
|
SnapshotRequested
{ forall tx. StateChanged tx -> Snapshot tx
snapshot :: Snapshot tx
, forall tx. StateChanged tx -> [TxIdType tx]
requestedTxIds :: [TxIdType tx]
, newLocalUTxO :: UTxOType tx
, forall tx. StateChanged tx -> [tx]
newLocalTxs :: [tx]
}
| PartySignedSnapshot {snapshot :: Snapshot tx, party :: Party, forall tx. StateChanged tx -> Signature (Snapshot tx)
signature :: Signature (Snapshot tx)}
| SnapshotConfirmed {headId :: HeadId, snapshot :: Snapshot tx, forall tx. StateChanged tx -> MultiSignature (Snapshot tx)
signatures :: MultiSignature (Snapshot tx)}
| CommitRecorded
{ chainState :: ChainStateType tx
, headId :: HeadId
, forall tx. StateChanged tx -> Map (TxIdType tx) (UTxOType tx)
pendingDeposits :: Map (TxIdType tx) (UTxOType tx)
, newLocalUTxO :: UTxOType tx
, forall tx. StateChanged tx -> UTxOType tx
utxoToCommit :: UTxOType tx
, forall tx. StateChanged tx -> TxIdType tx
pendingDeposit :: TxIdType tx
, forall tx. StateChanged tx -> UTCTime
deadline :: UTCTime
}
| CommitApproved {headId :: HeadId, utxoToCommit :: UTxOType tx}
| CommitRecovered
{ chainState :: ChainStateType tx
, headId :: HeadId
, forall tx. StateChanged tx -> UTxOType tx
recoveredUTxO :: UTxOType tx
, newLocalUTxO :: UTxOType tx
, forall tx. StateChanged tx -> TxIdType tx
recoveredTxId :: TxIdType tx
}
| CommitFinalized
{ chainState :: ChainStateType tx
, headId :: HeadId
, forall tx. StateChanged tx -> SnapshotVersion
newVersion :: SnapshotVersion
, forall tx. StateChanged tx -> TxIdType tx
depositTxId :: TxIdType tx
}
| DecommitRecorded {headId :: HeadId, forall tx. StateChanged tx -> tx
decommitTx :: tx, newLocalUTxO :: UTxOType tx, forall tx. StateChanged tx -> UTxOType tx
utxoToDecommit :: UTxOType tx}
| DecommitApproved {headId :: HeadId, forall tx. StateChanged tx -> TxIdType tx
decommitTxId :: TxIdType tx, utxoToDecommit :: UTxOType tx}
| DecommitInvalid {headId :: HeadId, decommitTx :: tx, forall tx. StateChanged tx -> DecommitInvalidReason tx
decommitInvalidReason :: DecommitInvalidReason tx}
| DecommitFinalized
{ chainState :: ChainStateType tx
, headId :: HeadId
, decommitTxId :: TxIdType tx
, newVersion :: SnapshotVersion
}
| HeadClosed {headId :: HeadId, snapshotNumber :: SnapshotNumber, chainState :: ChainStateType tx, forall tx. StateChanged tx -> UTCTime
contestationDeadline :: UTCTime}
| HeadContested {headId :: HeadId, chainState :: ChainStateType tx, contestationDeadline :: UTCTime, snapshotNumber :: SnapshotNumber}
| HeadIsReadyToFanout {headId :: HeadId}
| HeadFannedOut {headId :: HeadId, utxo :: UTxOType tx, chainState :: ChainStateType tx}
| ChainRolledBack {chainState :: ChainStateType tx}
| TickObserved {forall tx. StateChanged tx -> ChainSlot
chainSlot :: ChainSlot}
| IgnoredHeadInitializing
{ headId :: HeadId
, forall tx. StateChanged tx -> ContestationPeriod
contestationPeriod :: ContestationPeriod
, parties :: [Party]
, forall tx. StateChanged tx -> [OnChainId]
participants :: [OnChainId]
}
| TxInvalid {headId :: HeadId, utxo :: UTxOType tx, forall tx. StateChanged tx -> tx
transaction :: tx, forall tx. StateChanged tx -> ValidationError
validationError :: ValidationError}
| LocalStateCleared {headId :: HeadId, snapshotNumber :: SnapshotNumber}
deriving stock ((forall x. StateChanged tx -> Rep (StateChanged tx) x)
-> (forall x. Rep (StateChanged tx) x -> StateChanged tx)
-> Generic (StateChanged tx)
forall x. Rep (StateChanged tx) x -> StateChanged tx
forall x. StateChanged tx -> Rep (StateChanged tx) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall tx x. Rep (StateChanged tx) x -> StateChanged tx
forall tx x. StateChanged tx -> Rep (StateChanged tx) x
$cfrom :: forall tx x. StateChanged tx -> Rep (StateChanged tx) x
from :: forall x. StateChanged tx -> Rep (StateChanged tx) x
$cto :: forall tx x. Rep (StateChanged tx) x -> StateChanged tx
to :: forall x. Rep (StateChanged tx) x -> StateChanged tx
Generic)
deriving stock instance (IsChainState tx, IsTx tx, Eq (HeadState tx), Eq (ChainStateType tx)) => Eq (StateChanged tx)
deriving stock instance (IsChainState tx, IsTx tx, Show (HeadState tx), Show (ChainStateType tx)) => Show (StateChanged tx)
deriving anyclass instance (IsChainState tx, IsTx tx, ToJSON (ChainStateType tx)) => ToJSON (StateChanged tx)
deriving anyclass instance (IsChainState tx, IsTx tx, FromJSON (HeadState tx), FromJSON (ChainStateType tx)) => FromJSON (StateChanged tx)
instance (ArbitraryIsTx tx, IsChainState tx) => Arbitrary (StateChanged tx) where
arbitrary :: Gen (StateChanged tx)
arbitrary = Gen Environment
forall a. Arbitrary a => Gen a
arbitrary Gen Environment
-> (Environment -> Gen (StateChanged tx)) -> Gen (StateChanged tx)
forall a b. Gen a -> (a -> Gen b) -> Gen b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Environment -> Gen (StateChanged tx)
forall tx.
(ArbitraryIsTx tx, IsChainState tx) =>
Environment -> Gen (StateChanged tx)
genStateChanged
instance (ArbitraryIsTx tx, IsChainState tx) => ToADTArbitrary (StateChanged tx)
genStateChanged :: (ArbitraryIsTx tx, IsChainState tx) => Environment -> Gen (StateChanged tx)
genStateChanged :: forall tx.
(ArbitraryIsTx tx, IsChainState tx) =>
Environment -> Gen (StateChanged tx)
genStateChanged Environment
env =
[Gen (StateChanged tx)] -> Gen (StateChanged tx)
forall a. HasCallStack => [Gen a] -> Gen a
oneof
[ HeadParameters
-> ChainStateType tx
-> HeadId
-> HeadSeed
-> [Party]
-> StateChanged tx
forall tx.
HeadParameters
-> ChainStateType tx
-> HeadId
-> HeadSeed
-> [Party]
-> StateChanged tx
HeadInitialized (Environment -> HeadParameters
mkHeadParameters Environment
env) (ChainStateType tx
-> HeadId -> HeadSeed -> [Party] -> StateChanged tx)
-> Gen (ChainStateType tx)
-> Gen (HeadId -> HeadSeed -> [Party] -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (HeadId -> HeadSeed -> [Party] -> StateChanged tx)
-> Gen HeadId -> Gen (HeadSeed -> [Party] -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (HeadSeed -> [Party] -> StateChanged tx)
-> Gen HeadSeed -> Gen ([Party] -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen HeadSeed
forall a. Arbitrary a => Gen a
arbitrary Gen ([Party] -> StateChanged tx)
-> Gen [Party] -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [Party]
forall a. Arbitrary a => Gen a
arbitrary
, HeadId
-> Party -> UTxOType tx -> ChainStateType tx -> StateChanged tx
forall tx.
HeadId
-> Party -> UTxOType tx -> ChainStateType tx -> StateChanged tx
CommittedUTxO (HeadId
-> Party -> UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen HeadId
-> Gen
(Party -> UTxOType tx -> ChainStateType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (Party -> UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen Party
-> Gen (UTxOType tx -> ChainStateType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Party -> Gen Party
forall a. a -> Gen a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Party
party Gen (UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (ChainStateType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (ChainStateType tx -> StateChanged tx)
-> Gen (ChainStateType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> UTxOType tx -> ChainStateType tx -> StateChanged tx
forall tx.
HeadId -> UTxOType tx -> ChainStateType tx -> StateChanged tx
HeadAborted (HeadId -> UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen HeadId
-> Gen (UTxOType tx -> ChainStateType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (ChainStateType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (ChainStateType tx -> StateChanged tx)
-> Gen (ChainStateType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> ChainStateType tx -> UTxOType tx -> StateChanged tx
forall tx.
HeadId -> ChainStateType tx -> UTxOType tx -> StateChanged tx
HeadOpened (HeadId -> ChainStateType tx -> UTxOType tx -> StateChanged tx)
-> Gen HeadId
-> Gen (ChainStateType tx -> UTxOType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (ChainStateType tx -> UTxOType tx -> StateChanged tx)
-> Gen (ChainStateType tx) -> Gen (UTxOType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary
, tx -> StateChanged tx
forall tx. tx -> StateChanged tx
TransactionReceived (tx -> StateChanged tx) -> Gen tx -> Gen (StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen tx
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> tx -> UTxOType tx -> StateChanged tx
forall tx. HeadId -> tx -> UTxOType tx -> StateChanged tx
TransactionAppliedToLocalUTxO (HeadId -> tx -> UTxOType tx -> StateChanged tx)
-> Gen HeadId -> Gen (tx -> UTxOType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (tx -> UTxOType tx -> StateChanged tx)
-> Gen tx -> Gen (UTxOType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen tx
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary
, SnapshotNumber -> StateChanged tx
forall tx. SnapshotNumber -> StateChanged tx
SnapshotRequestDecided (SnapshotNumber -> StateChanged tx)
-> Gen SnapshotNumber -> Gen (StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen SnapshotNumber
forall a. Arbitrary a => Gen a
arbitrary
, Snapshot tx
-> [TxIdType tx] -> UTxOType tx -> [tx] -> StateChanged tx
forall tx.
Snapshot tx
-> [TxIdType tx] -> UTxOType tx -> [tx] -> StateChanged tx
SnapshotRequested (Snapshot tx
-> [TxIdType tx] -> UTxOType tx -> [tx] -> StateChanged tx)
-> Gen (Snapshot tx)
-> Gen ([TxIdType tx] -> UTxOType tx -> [tx] -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Snapshot tx)
forall a. Arbitrary a => Gen a
arbitrary Gen ([TxIdType tx] -> UTxOType tx -> [tx] -> StateChanged tx)
-> Gen [TxIdType tx]
-> Gen (UTxOType tx -> [tx] -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [TxIdType tx]
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> [tx] -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen ([tx] -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen ([tx] -> StateChanged tx) -> Gen [tx] -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen [tx]
forall a. Arbitrary a => Gen a
arbitrary
, Snapshot tx -> Party -> Signature (Snapshot tx) -> StateChanged tx
forall tx.
Snapshot tx -> Party -> Signature (Snapshot tx) -> StateChanged tx
PartySignedSnapshot (Snapshot tx
-> Party -> Signature (Snapshot tx) -> StateChanged tx)
-> Gen (Snapshot tx)
-> Gen (Party -> Signature (Snapshot tx) -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Snapshot tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (Party -> Signature (Snapshot tx) -> StateChanged tx)
-> Gen Party -> Gen (Signature (Snapshot tx) -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Party
forall a. Arbitrary a => Gen a
arbitrary Gen (Signature (Snapshot tx) -> StateChanged tx)
-> Gen (Signature (Snapshot tx)) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Signature (Snapshot tx))
forall a. Arbitrary a => Gen a
arbitrary
, HeadId
-> Snapshot tx -> MultiSignature (Snapshot tx) -> StateChanged tx
forall tx.
HeadId
-> Snapshot tx -> MultiSignature (Snapshot tx) -> StateChanged tx
SnapshotConfirmed (HeadId
-> Snapshot tx -> MultiSignature (Snapshot tx) -> StateChanged tx)
-> Gen HeadId
-> Gen
(Snapshot tx -> MultiSignature (Snapshot tx) -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen
(Snapshot tx -> MultiSignature (Snapshot tx) -> StateChanged tx)
-> Gen (Snapshot tx)
-> Gen (MultiSignature (Snapshot tx) -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Snapshot tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (MultiSignature (Snapshot tx) -> StateChanged tx)
-> Gen (MultiSignature (Snapshot tx)) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (MultiSignature (Snapshot tx))
forall a. Arbitrary a => Gen a
arbitrary
, ChainStateType tx
-> HeadId
-> Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx
forall tx.
ChainStateType tx
-> HeadId
-> Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx
CommitRecorded (ChainStateType tx
-> HeadId
-> Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx)
-> Gen (ChainStateType tx)
-> Gen
(HeadId
-> Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen
(HeadId
-> Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx)
-> Gen HeadId
-> Gen
(Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen
(Map (TxIdType tx) (UTxOType tx)
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> UTCTime
-> StateChanged tx)
-> Gen (Map (TxIdType tx) (UTxOType tx))
-> Gen
(UTxOType tx
-> UTxOType tx -> TxIdType tx -> UTCTime -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (Map (TxIdType tx) (UTxOType tx))
forall a. Arbitrary a => Gen a
arbitrary Gen
(UTxOType tx
-> UTxOType tx -> TxIdType tx -> UTCTime -> StateChanged tx)
-> Gen (UTxOType tx)
-> Gen (UTxOType tx -> TxIdType tx -> UTCTime -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> TxIdType tx -> UTCTime -> StateChanged tx)
-> Gen (UTxOType tx)
-> Gen (TxIdType tx -> UTCTime -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (TxIdType tx -> UTCTime -> StateChanged tx)
-> Gen (TxIdType tx) -> Gen (UTCTime -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (TxIdType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTCTime -> StateChanged tx)
-> Gen UTCTime -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen UTCTime
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> UTxOType tx -> StateChanged tx
forall tx. HeadId -> UTxOType tx -> StateChanged tx
CommitApproved (HeadId -> UTxOType tx -> StateChanged tx)
-> Gen HeadId -> Gen (UTxOType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary
, ChainStateType tx
-> HeadId
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> StateChanged tx
forall tx.
ChainStateType tx
-> HeadId
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> StateChanged tx
CommitRecovered (ChainStateType tx
-> HeadId
-> UTxOType tx
-> UTxOType tx
-> TxIdType tx
-> StateChanged tx)
-> Gen (ChainStateType tx)
-> Gen
(HeadId
-> UTxOType tx -> UTxOType tx -> TxIdType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen
(HeadId
-> UTxOType tx -> UTxOType tx -> TxIdType tx -> StateChanged tx)
-> Gen HeadId
-> Gen
(UTxOType tx -> UTxOType tx -> TxIdType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> UTxOType tx -> TxIdType tx -> StateChanged tx)
-> Gen (UTxOType tx)
-> Gen (UTxOType tx -> TxIdType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> TxIdType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (TxIdType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (TxIdType tx -> StateChanged tx)
-> Gen (TxIdType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (TxIdType tx)
forall a. Arbitrary a => Gen a
arbitrary
, ChainStateType tx
-> HeadId -> SnapshotVersion -> TxIdType tx -> StateChanged tx
forall tx.
ChainStateType tx
-> HeadId -> SnapshotVersion -> TxIdType tx -> StateChanged tx
CommitFinalized (ChainStateType tx
-> HeadId -> SnapshotVersion -> TxIdType tx -> StateChanged tx)
-> Gen (ChainStateType tx)
-> Gen
(HeadId -> SnapshotVersion -> TxIdType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (HeadId -> SnapshotVersion -> TxIdType tx -> StateChanged tx)
-> Gen HeadId
-> Gen (SnapshotVersion -> TxIdType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (SnapshotVersion -> TxIdType tx -> StateChanged tx)
-> Gen SnapshotVersion -> Gen (TxIdType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen SnapshotVersion
forall a. Arbitrary a => Gen a
arbitrary Gen (TxIdType tx -> StateChanged tx)
-> Gen (TxIdType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (TxIdType tx)
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> tx -> UTxOType tx -> UTxOType tx -> StateChanged tx
forall tx.
HeadId -> tx -> UTxOType tx -> UTxOType tx -> StateChanged tx
DecommitRecorded (HeadId -> tx -> UTxOType tx -> UTxOType tx -> StateChanged tx)
-> Gen HeadId
-> Gen (tx -> UTxOType tx -> UTxOType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (tx -> UTxOType tx -> UTxOType tx -> StateChanged tx)
-> Gen tx -> Gen (UTxOType tx -> UTxOType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen tx
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> UTxOType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (UTxOType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> TxIdType tx -> UTxOType tx -> StateChanged tx
forall tx. HeadId -> TxIdType tx -> UTxOType tx -> StateChanged tx
DecommitApproved (HeadId -> TxIdType tx -> UTxOType tx -> StateChanged tx)
-> Gen HeadId
-> Gen (TxIdType tx -> UTxOType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (TxIdType tx -> UTxOType tx -> StateChanged tx)
-> Gen (TxIdType tx) -> Gen (UTxOType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (TxIdType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> tx -> DecommitInvalidReason tx -> StateChanged tx
forall tx.
HeadId -> tx -> DecommitInvalidReason tx -> StateChanged tx
DecommitInvalid (HeadId -> tx -> DecommitInvalidReason tx -> StateChanged tx)
-> Gen HeadId
-> Gen (tx -> DecommitInvalidReason tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (tx -> DecommitInvalidReason tx -> StateChanged tx)
-> Gen tx -> Gen (DecommitInvalidReason tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen tx
forall a. Arbitrary a => Gen a
arbitrary Gen (DecommitInvalidReason tx -> StateChanged tx)
-> Gen (DecommitInvalidReason tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (DecommitInvalidReason tx)
forall a. Arbitrary a => Gen a
arbitrary
, ChainStateType tx
-> HeadId -> TxIdType tx -> SnapshotVersion -> StateChanged tx
forall tx.
ChainStateType tx
-> HeadId -> TxIdType tx -> SnapshotVersion -> StateChanged tx
DecommitFinalized (ChainStateType tx
-> HeadId -> TxIdType tx -> SnapshotVersion -> StateChanged tx)
-> Gen (ChainStateType tx)
-> Gen
(HeadId -> TxIdType tx -> SnapshotVersion -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (HeadId -> TxIdType tx -> SnapshotVersion -> StateChanged tx)
-> Gen HeadId
-> Gen (TxIdType tx -> SnapshotVersion -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (TxIdType tx -> SnapshotVersion -> StateChanged tx)
-> Gen (TxIdType tx) -> Gen (SnapshotVersion -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (TxIdType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (SnapshotVersion -> StateChanged tx)
-> Gen SnapshotVersion -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen SnapshotVersion
forall a. Arbitrary a => Gen a
arbitrary
, HeadId
-> SnapshotNumber
-> ChainStateType tx
-> UTCTime
-> StateChanged tx
forall tx.
HeadId
-> SnapshotNumber
-> ChainStateType tx
-> UTCTime
-> StateChanged tx
HeadClosed (HeadId
-> SnapshotNumber
-> ChainStateType tx
-> UTCTime
-> StateChanged tx)
-> Gen HeadId
-> Gen
(SnapshotNumber -> ChainStateType tx -> UTCTime -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen
(SnapshotNumber -> ChainStateType tx -> UTCTime -> StateChanged tx)
-> Gen SnapshotNumber
-> Gen (ChainStateType tx -> UTCTime -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen SnapshotNumber
forall a. Arbitrary a => Gen a
arbitrary Gen (ChainStateType tx -> UTCTime -> StateChanged tx)
-> Gen (ChainStateType tx) -> Gen (UTCTime -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTCTime -> StateChanged tx)
-> Gen UTCTime -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen UTCTime
forall a. Arbitrary a => Gen a
arbitrary
, HeadId
-> ChainStateType tx
-> UTCTime
-> SnapshotNumber
-> StateChanged tx
forall tx.
HeadId
-> ChainStateType tx
-> UTCTime
-> SnapshotNumber
-> StateChanged tx
HeadContested (HeadId
-> ChainStateType tx
-> UTCTime
-> SnapshotNumber
-> StateChanged tx)
-> Gen HeadId
-> Gen
(ChainStateType tx -> UTCTime -> SnapshotNumber -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen
(ChainStateType tx -> UTCTime -> SnapshotNumber -> StateChanged tx)
-> Gen (ChainStateType tx)
-> Gen (UTCTime -> SnapshotNumber -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (UTCTime -> SnapshotNumber -> StateChanged tx)
-> Gen UTCTime -> Gen (SnapshotNumber -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen UTCTime
forall a. Arbitrary a => Gen a
arbitrary Gen (SnapshotNumber -> StateChanged tx)
-> Gen SnapshotNumber -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen SnapshotNumber
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> StateChanged tx
forall tx. HeadId -> StateChanged tx
HeadIsReadyToFanout (HeadId -> StateChanged tx) -> Gen HeadId -> Gen (StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> UTxOType tx -> ChainStateType tx -> StateChanged tx
forall tx.
HeadId -> UTxOType tx -> ChainStateType tx -> StateChanged tx
HeadFannedOut (HeadId -> UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen HeadId
-> Gen (UTxOType tx -> ChainStateType tx -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (UTxOType tx -> ChainStateType tx -> StateChanged tx)
-> Gen (UTxOType tx) -> Gen (ChainStateType tx -> StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (UTxOType tx)
forall a. Arbitrary a => Gen a
arbitrary Gen (ChainStateType tx -> StateChanged tx)
-> Gen (ChainStateType tx) -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen (ChainStateType tx)
forall a. Arbitrary a => Gen a
arbitrary
, HeadId -> SnapshotNumber -> StateChanged tx
forall tx. HeadId -> SnapshotNumber -> StateChanged tx
LocalStateCleared (HeadId -> SnapshotNumber -> StateChanged tx)
-> Gen HeadId -> Gen (SnapshotNumber -> StateChanged tx)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen HeadId
forall a. Arbitrary a => Gen a
arbitrary Gen (SnapshotNumber -> StateChanged tx)
-> Gen SnapshotNumber -> Gen (StateChanged tx)
forall a b. Gen (a -> b) -> Gen a -> Gen b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen SnapshotNumber
forall a. Arbitrary a => Gen a
arbitrary
]
where
Environment{Party
party :: Party
$sel:party:Environment :: Environment -> Party
party} = Environment
env
data Outcome tx
=
Continue {forall tx. Outcome tx -> [StateChanged tx]
stateChanges :: [StateChanged tx], forall tx. Outcome tx -> [Effect tx]
effects :: [Effect tx]}
|
Wait {forall tx. Outcome tx -> WaitReason tx
reason :: WaitReason tx, stateChanges :: [StateChanged tx]}
|
Error {forall tx. Outcome tx -> LogicError tx
error :: LogicError tx}
deriving stock ((forall x. Outcome tx -> Rep (Outcome tx) x)
-> (forall x. Rep (Outcome tx) x -> Outcome tx)
-> Generic (Outcome tx)
forall x. Rep (Outcome tx) x -> Outcome tx
forall x. Outcome tx -> Rep (Outcome tx) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall tx x. Rep (Outcome tx) x -> Outcome tx
forall tx x. Outcome tx -> Rep (Outcome tx) x
$cfrom :: forall tx x. Outcome tx -> Rep (Outcome tx) x
from :: forall x. Outcome tx -> Rep (Outcome tx) x
$cto :: forall tx x. Rep (Outcome tx) x -> Outcome tx
to :: forall x. Rep (Outcome tx) x -> Outcome tx
Generic)
instance Semigroup (Outcome tx) where
e :: Outcome tx
e@Error{} <> :: Outcome tx -> Outcome tx -> Outcome tx
<> Outcome tx
_ = Outcome tx
e
Outcome tx
_ <> e :: Outcome tx
e@Error{} = Outcome tx
e
Continue [StateChanged tx]
scA [Effect tx]
_ <> Wait WaitReason tx
r [StateChanged tx]
scB = WaitReason tx -> [StateChanged tx] -> Outcome tx
forall tx. WaitReason tx -> [StateChanged tx] -> Outcome tx
Wait WaitReason tx
r ([StateChanged tx]
scA [StateChanged tx] -> [StateChanged tx] -> [StateChanged tx]
forall a. Semigroup a => a -> a -> a
<> [StateChanged tx]
scB)
Wait WaitReason tx
r [StateChanged tx]
scA <> Outcome tx
_ = WaitReason tx -> [StateChanged tx] -> Outcome tx
forall tx. WaitReason tx -> [StateChanged tx] -> Outcome tx
Wait WaitReason tx
r [StateChanged tx]
scA
Continue [StateChanged tx]
scA [Effect tx]
efA <> Continue [StateChanged tx]
scB [Effect tx]
efB = [StateChanged tx] -> [Effect tx] -> Outcome tx
forall tx. [StateChanged tx] -> [Effect tx] -> Outcome tx
Continue ([StateChanged tx]
scA [StateChanged tx] -> [StateChanged tx] -> [StateChanged tx]
forall a. Semigroup a => a -> a -> a
<> [StateChanged tx]
scB) ([Effect tx]
efA [Effect tx] -> [Effect tx] -> [Effect tx]
forall a. Semigroup a => a -> a -> a
<> [Effect tx]
efB)
deriving stock instance IsChainState tx => Eq (Outcome tx)
deriving stock instance IsChainState tx => Show (Outcome tx)
deriving anyclass instance IsChainState tx => ToJSON (Outcome tx)
instance (ArbitraryIsTx tx, IsChainState tx) => Arbitrary (Outcome tx) where
arbitrary :: Gen (Outcome tx)
arbitrary = Gen (Outcome tx)
forall a.
(Generic a, GA UnsizedOpts (Rep a),
UniformWeight (Weights_ (Rep a))) =>
Gen a
genericArbitrary
shrink :: Outcome tx -> [Outcome tx]
shrink = Outcome tx -> [Outcome tx]
forall a.
(Generic a, RecursivelyShrink (Rep a), GSubterms (Rep a) a) =>
a -> [a]
genericShrink
noop :: Outcome tx
noop :: forall tx. Outcome tx
noop = [StateChanged tx] -> [Effect tx] -> Outcome tx
forall tx. [StateChanged tx] -> [Effect tx] -> Outcome tx
Continue [] []
wait :: WaitReason tx -> Outcome tx
wait :: forall tx. WaitReason tx -> Outcome tx
wait WaitReason tx
reason = WaitReason tx -> [StateChanged tx] -> Outcome tx
forall tx. WaitReason tx -> [StateChanged tx] -> Outcome tx
Wait WaitReason tx
reason []
newState :: StateChanged tx -> Outcome tx
newState :: forall tx. StateChanged tx -> Outcome tx
newState StateChanged tx
change = [StateChanged tx] -> [Effect tx] -> Outcome tx
forall tx. [StateChanged tx] -> [Effect tx] -> Outcome tx
Continue [StateChanged tx
change] []
cause :: Effect tx -> Outcome tx
cause :: forall tx. Effect tx -> Outcome tx
cause Effect tx
e = [StateChanged tx] -> [Effect tx] -> Outcome tx
forall tx. [StateChanged tx] -> [Effect tx] -> Outcome tx
Continue [] [Effect tx
e]
causes :: [Effect tx] -> Outcome tx
causes :: forall tx. [Effect tx] -> Outcome tx
causes = [StateChanged tx] -> [Effect tx] -> Outcome tx
forall tx. [StateChanged tx] -> [Effect tx] -> Outcome tx
Continue []
changes :: [StateChanged tx] -> Outcome tx
changes :: forall tx. [StateChanged tx] -> Outcome tx
changes [StateChanged tx]
stateChanges = [StateChanged tx] -> [Effect tx] -> Outcome tx
forall tx. [StateChanged tx] -> [Effect tx] -> Outcome tx
Continue [StateChanged tx]
stateChanges []
data WaitReason tx
= WaitOnNotApplicableTx {forall tx. WaitReason tx -> ValidationError
validationError :: ValidationError}
| WaitOnSnapshotNumber {forall tx. WaitReason tx -> SnapshotNumber
waitingForNumber :: SnapshotNumber}
| WaitOnSnapshotVersion {forall tx. WaitReason tx -> SnapshotVersion
waitingForVersion :: SnapshotVersion}
| WaitOnSeenSnapshot
| WaitOnTxs {forall tx. WaitReason tx -> [TxIdType tx]
waitingForTxIds :: [TxIdType tx]}
| WaitOnContestationDeadline
| WaitOnNotApplicableDecommitTx {forall tx. WaitReason tx -> DecommitInvalidReason tx
notApplicableReason :: DecommitInvalidReason tx}
| WaitOnUnresolvedCommit {forall tx. WaitReason tx -> UTxOType tx
commitUTxO :: UTxOType tx}
| WaitOnUnresolvedDecommit {forall tx. WaitReason tx -> tx
decommitTx :: tx}
deriving stock ((forall x. WaitReason tx -> Rep (WaitReason tx) x)
-> (forall x. Rep (WaitReason tx) x -> WaitReason tx)
-> Generic (WaitReason tx)
forall x. Rep (WaitReason tx) x -> WaitReason tx
forall x. WaitReason tx -> Rep (WaitReason tx) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall tx x. Rep (WaitReason tx) x -> WaitReason tx
forall tx x. WaitReason tx -> Rep (WaitReason tx) x
$cfrom :: forall tx x. WaitReason tx -> Rep (WaitReason tx) x
from :: forall x. WaitReason tx -> Rep (WaitReason tx) x
$cto :: forall tx x. Rep (WaitReason tx) x -> WaitReason tx
to :: forall x. Rep (WaitReason tx) x -> WaitReason tx
Generic)
deriving stock instance IsTx tx => Eq (WaitReason tx)
deriving stock instance IsTx tx => Show (WaitReason tx)
deriving anyclass instance IsTx tx => ToJSON (WaitReason tx)
instance ArbitraryIsTx tx => Arbitrary (WaitReason tx) where
arbitrary :: Gen (WaitReason tx)
arbitrary = Gen (WaitReason tx)
forall a.
(Generic a, GA UnsizedOpts (Rep a),
UniformWeight (Weights_ (Rep a))) =>
Gen a
genericArbitrary