| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Tx.Observe
Description
Observe hydra transactions
Synopsis
- data HeadObservation
- = NoHeadTx
- | Init InitObservation
- | Deposit DepositObservation
- | Recover RecoverObservation
- | Increment IncrementObservation
- | Decrement DecrementObservation
- | Close CloseObservation
- | Contest ContestObservation
- | PartialFanout PartialFanoutObservation
- | Fanout FanoutObservation
- | FinalPartialFanout FanoutObservation
- observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation
- observeHeadTxWithReason :: NetworkId -> UTxO -> Tx -> (HeadObservation, Maybe NotAnInitReason)
- data InitObservation = InitObservation {}
- data NotAnInitReason
- isMalformedInit :: NotAnInitReason -> Bool
- observeInitTx :: Tx -> Either NotAnInitReason InitObservation
- data DecrementObservation = DecrementObservation {
- headId :: HeadId
- newVersion :: SnapshotVersion
- distributedUTxO :: UTxO
- snapshotNumber :: SnapshotNumber
- signatures :: MultiSignature (Snapshot Tx)
- observeDecrementTx :: UTxO -> Tx -> Maybe DecrementObservation
- data DepositObservation = DepositObservation {}
- observeDepositTx :: NetworkId -> Tx -> Maybe DepositObservation
- data IncrementObservation = IncrementObservation {
- headId :: HeadId
- newVersion :: SnapshotVersion
- depositTxId :: TxId
- deposited :: UTxO
- snapshotNumber :: SnapshotNumber
- signatures :: MultiSignature (Snapshot Tx)
- observeIncrementTx :: NetworkId -> UTxO -> Tx -> Maybe IncrementObservation
- data RecoverObservation = RecoverObservation {
- headId :: HeadId
- recoveredTxId :: TxId
- recoveredUTxO :: UTxO
- observeRecoverTx :: NetworkId -> UTxO -> Tx -> Maybe RecoverObservation
- data CloseObservation = CloseObservation {}
- observeCloseTx :: UTxO -> Tx -> Maybe CloseObservation
- data ContestObservation = ContestObservation {
- headId :: HeadId
- snapshotNumber :: SnapshotNumber
- contestationDeadline :: UTCTime
- contesters :: [PubKeyHash]
- signatures :: MultiSignature (Snapshot Tx)
- observeContestTx :: UTxO -> Tx -> Maybe ContestObservation
- data FanoutObservation = FanoutObservation {
- headId :: HeadId
- fanoutUTxO :: UTxO
- data PartialFanoutObservation = PartialFanoutObservation {
- headId :: HeadId
- distributedOutputs :: UTxO
- observeFanoutTx :: UTxO -> Tx -> Maybe FanoutObservation
- observeFinalPartialFanoutTx :: UTxO -> Tx -> Maybe FanoutObservation
- observePartialFanoutTx :: UTxO -> Tx -> Maybe PartialFanoutObservation
Documentation
data HeadObservation Source #
Generalised type for arbitrary Head observations on-chain.
Constructors
Instances
observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation Source #
Observe any Hydra head transaction.
observeHeadTxWithReason :: NetworkId -> UTxO -> Tx -> (HeadObservation, Maybe NotAnInitReason) Source #
Like observeHeadTx, but also reports why a transaction that really did
mint a head's tokens was rejected as an init (see isMalformedInit). There is
nothing to act on in that case - hence the HeadObservation is unaffected -
but it is worth logging, as the minting policy constrains none of the datum
fields involved.
data InitObservation Source #
Data which can be observed from an initTx.
Constructors
| InitObservation | |
Fields
| |
Instances
data NotAnInitReason Source #
Constructors
| NoHeadOutput | |
| NotAHeadDatum | |
| InvalidPartyInDatum | |
| InvalidContestationPeriodInDatum Text | |
| InvalidDepositPeriodInDatum Text | |
| NoSTFound | |
| NotAHeadPolicy | |
| NoTokensMinted |
Instances
isMalformedInit :: NotAnInitReason -> Bool Source #
Whether the reason describes a transaction that really did mint this head's tokens but carries a datum the node cannot use, as opposed to a transaction that is simply not an init. Only the former is worth reporting: the latter fires for every unrelated transaction on the chain, and for every increment/decrement.
observeInitTx :: Tx -> Either NotAnInitReason InitObservation Source #
Identify a init tx by checking the output value for holding tokens that are valid head tokens (checked by seed + policy).
data DecrementObservation Source #
Constructors
| DecrementObservation | |
Fields
| |
Instances
observeDecrementTx :: UTxO -> Tx -> Maybe DecrementObservation Source #
data DepositObservation Source #
Constructors
| DepositObservation | |
Instances
observeDepositTx :: NetworkId -> Tx -> Maybe DepositObservation Source #
Observe a deposit transaction by its shape: the deposit output and its
datum alone. Nothing here tells a deposit from a head transaction that
happens to produce such an output first (a fanout can), so when classifying
arbitrary chain transactions use observeHeadTx, which
tries the head observers first and skips this one for any transaction
spending a head output.
data IncrementObservation Source #
Constructors
| IncrementObservation | |
Fields
| |
Instances
observeIncrementTx :: NetworkId -> UTxO -> Tx -> Maybe IncrementObservation Source #
data RecoverObservation Source #
Constructors
| RecoverObservation | |
Fields
| |
Instances
observeRecoverTx :: NetworkId -> UTxO -> Tx -> Maybe RecoverObservation Source #
data CloseObservation Source #
Constructors
| CloseObservation | |
Fields
| |
Instances
Arguments
| :: UTxO | A UTxO set to lookup tx inputs |
| -> Tx | |
| -> Maybe CloseObservation |
Identify a close tx by lookup up the input spending the Head output and decoding its redeemer.
data ContestObservation Source #
Constructors
| ContestObservation | |
Fields
| |
Instances
Arguments
| :: UTxO | A UTxO set to lookup tx inputs |
| -> Tx | |
| -> Maybe ContestObservation |
Identify a contest tx by lookup up the input spending the Head output and decoding its redeemer.
data FanoutObservation Source #
Constructors
| FanoutObservation | |
Fields
| |
Instances
data PartialFanoutObservation Source #
Constructors
| PartialFanoutObservation | |
Fields
| |
Instances
Arguments
| :: UTxO | A UTxO set to lookup tx inputs |
| -> Tx | |
| -> Maybe FanoutObservation |
Identify a fanout tx by lookup up the input spending the Head output and decoding its redeemer.
observeFinalPartialFanoutTx Source #
Arguments
| :: UTxO | A UTxO set to lookup tx inputs |
| -> Tx | |
| -> Maybe FanoutObservation |
Identify a final partial fanout tx by looking up the input spending the Head output and decoding its redeemer as FinalPartialFanout. Returns a FanoutObservation since this is the finalizing step.
observePartialFanoutTx Source #
Arguments
| :: UTxO | A UTxO set to lookup tx inputs |
| -> Tx | |
| -> Maybe PartialFanoutObservation |
Identify a partial fanout tx by looking up the input spending the Head output and decoding its redeemer as PartialFanout.