hydra-node-0.16.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.API.ServerOutput

Synopsis

Documentation

data TimedServerOutput tx Source #

The type of messages sent to clients by the Server.

Constructors

TimedServerOutput 

Fields

Instances

Instances details
Arbitrary (ServerOutput tx) => Arbitrary (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

IsChainState tx => FromJSON (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

parseJSON :: Value -> Parser (TimedServerOutput tx)

parseJSONList :: Value -> Parser [TimedServerOutput tx]

omittedField :: Maybe (TimedServerOutput tx)

IsChainState tx => ToJSON (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

toJSON :: TimedServerOutput tx -> Value

toEncoding :: TimedServerOutput tx -> Encoding

toJSONList :: [TimedServerOutput tx] -> Value

toEncodingList :: [TimedServerOutput tx] -> Encoding

omitField :: TimedServerOutput tx -> Bool

Generic (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Associated Types

type Rep (TimedServerOutput tx) :: Type -> Type Source #

IsChainState tx => Show (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

IsChainState tx => Eq (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

type Rep (TimedServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

type Rep (TimedServerOutput tx) = D1 ('MetaData "TimedServerOutput" "Hydra.API.ServerOutput" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'False) (C1 ('MetaCons "TimedServerOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "output") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ServerOutput tx)) :*: (S1 ('MetaSel ('Just "seq") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Natural) :*: S1 ('MetaSel ('Just "time") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime))))

genTimedServerOutput :: ServerOutput tx -> Gen (TimedServerOutput tx) Source #

Generate a random timed server output given a normal server output.

data ServerOutput tx Source #

Individual server output messages as produced by the HeadLogic in the ClientEffect.

Constructors

PeerConnected 

Fields

PeerDisconnected 

Fields

HeadIsInitializing 

Fields

Committed 

Fields

HeadIsOpen 

Fields

HeadIsClosed 

Fields

HeadIsContested 

Fields

ReadyToFanout 

Fields

HeadIsAborted 

Fields

HeadIsFinalized 

Fields

CommandFailed 

Fields

TxValid

Given transaction has been seen as valid in the Head. It is expected to eventually be part of a SnapshotConfirmed.

Fields

TxInvalid

Given transaction was not not applicable to the given UTxO in time and has been dropped.

SnapshotConfirmed

Given snapshot was confirmed and included transactions can be considered final.

GetUTxOResponse 

Fields

InvalidInput 

Fields

Greetings

A friendly welcome message which tells a client something about the node. Currently used for knowing what signing key the server uses (it only knows one), HeadStatus and optionally (if HeadIsOpen or SnapshotConfirmed message is emitted) UTxO's present in the Hydra Head.

PostTxOnChainFailed 
IgnoredHeadInitializing 

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType tx)) => Arbitrary (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

arbitrary :: Gen (ServerOutput tx)

shrink :: ServerOutput tx -> [ServerOutput tx]

IsChainState tx => FromJSON (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

parseJSON :: Value -> Parser (ServerOutput tx)

parseJSONList :: Value -> Parser [ServerOutput tx]

omittedField :: Maybe (ServerOutput tx)

IsChainState tx => ToJSON (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

toJSON :: ServerOutput tx -> Value

toEncoding :: ServerOutput tx -> Encoding

toJSONList :: [ServerOutput tx] -> Value

toEncodingList :: [ServerOutput tx] -> Encoding

omitField :: ServerOutput tx -> Bool

Generic (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

Associated Types

type Rep (ServerOutput tx) :: Type -> Type Source #

IsChainState tx => Show (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

IsChainState tx => Eq (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

type Rep (ServerOutput tx) Source # 
Instance details

Defined in Hydra.API.ServerOutput

type Rep (ServerOutput tx) = D1 ('MetaData "ServerOutput" "Hydra.API.ServerOutput" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'False) ((((C1 ('MetaCons "PeerConnected" 'PrefixI 'True) (S1 ('MetaSel ('Just "peer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeId)) :+: C1 ('MetaCons "PeerDisconnected" 'PrefixI 'True) (S1 ('MetaSel ('Just "peer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NodeId))) :+: (C1 ('MetaCons "HeadIsInitializing" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "parties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party])) :+: C1 ('MetaCons "Committed" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)))))) :+: ((C1 ('MetaCons "HeadIsOpen" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "HeadIsClosed" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime)))) :+: (C1 ('MetaCons "HeadIsContested" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime))) :+: (C1 ('MetaCons "ReadyToFanout" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)) :+: C1 ('MetaCons "HeadIsAborted" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))))))) :+: (((C1 ('MetaCons "HeadIsFinalized" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "CommandFailed" 'PrefixI 'True) (S1 ('MetaSel ('Just "clientInput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ClientInput tx)) :*: S1 ('MetaSel ('Just "state") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (HeadState tx)))) :+: (C1 ('MetaCons "TxValid" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "transaction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx)) :+: (C1 ('MetaCons "TxInvalid" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :*: (S1 ('MetaSel ('Just "transaction") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx) :*: S1 ('MetaSel ('Just "validationError") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ValidationError))) :+: C1 ('MetaCons "SnapshotConfirmed" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "snapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Snapshot tx)) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot tx)))))))) :+: ((C1 ('MetaCons "GetUTxOResponse" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "InvalidInput" 'PrefixI 'True) (S1 ('MetaSel ('Just "reason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: S1 ('MetaSel ('Just "input") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text))) :+: (C1 ('MetaCons "Greetings" 'PrefixI 'True) ((S1 ('MetaSel ('Just "me") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "headStatus") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadStatus)) :*: (S1 ('MetaSel ('Just "snapshotUtxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (UTxOType tx))) :*: S1 ('MetaSel ('Just "hydraNodeVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String))) :+: (C1 ('MetaCons "PostTxOnChainFailed" 'PrefixI 'True) (S1 ('MetaSel ('Just "postChainTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PostChainTx tx)) :*: S1 ('MetaSel ('Just "postTxError") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PostTxError tx))) :+: C1 ('MetaCons "IgnoredHeadInitializing" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "contestationPeriod") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContestationPeriod)) :*: (S1 ('MetaSel ('Just "parties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party]) :*: S1 ('MetaSel ('Just "participants") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [OnChainId]))))))))

data WithUTxO Source #

Whether or not to include full UTxO in server outputs.

Constructors

WithUTxO 
WithoutUTxO 

Instances

Instances details
Show WithUTxO Source # 
Instance details

Defined in Hydra.API.ServerOutput

Eq WithUTxO Source # 
Instance details

Defined in Hydra.API.ServerOutput

prepareServerOutput Source #

Arguments

:: IsChainState tx 
=> ServerOutputConfig

Decide on tx representation

-> TimedServerOutput tx

Server output

-> ByteString

Final output

Replaces the json encoded tx field with it's cbor representation.

NOTE: we deliberately pattern match on all ServerOutput constructors in handleTxOutput so that we don't forget to update this function if they change.

data HeadStatus Source #

All possible Hydra states displayed in the API server outputs.

Instances

Instances details
Arbitrary HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

FromJSON HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

parseJSON :: Value -> Parser HeadStatus

parseJSONList :: Value -> Parser [HeadStatus]

omittedField :: Maybe HeadStatus

ToJSON HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

Methods

toJSON :: HeadStatus -> Value

toEncoding :: HeadStatus -> Encoding

toJSONList :: [HeadStatus] -> Value

toEncodingList :: [HeadStatus] -> Encoding

omitField :: HeadStatus -> Bool

Generic HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

Associated Types

type Rep HeadStatus :: Type -> Type Source #

Show HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

Eq HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

type Rep HeadStatus Source # 
Instance details

Defined in Hydra.API.ServerOutput

type Rep HeadStatus = D1 ('MetaData "HeadStatus" "Hydra.API.ServerOutput" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'False) ((C1 ('MetaCons "Idle" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "Initializing" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Open" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "Closed" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FanoutPossible" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Final" 'PrefixI 'False) (U1 :: Type -> Type))))

projectInitializingHeadId :: Maybe HeadId -> ServerOutput tx -> Maybe HeadId Source #

Projection to obtain the HeadId needed to draft a commit transaction. NOTE: We only want to project HeadId when the Head is in the Initializing state since this is when Head parties need to commit some funds.

projectHeadStatus :: HeadStatus -> ServerOutput tx -> HeadStatus Source #

Projection function related to $sel:headStatus:PeerConnected field in Greetings message.

projectSnapshotUtxo :: Maybe (UTxOType tx) -> ServerOutput tx -> Maybe (UTxOType tx) Source #

Projection function related to $sel:snapshotUtxo:PeerConnected field in Greetings message.