hydra-tx
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Tx.Observe

Description

Observe hydra transactions

Synopsis

Documentation

data HeadObservation Source #

Generalised type for arbitrary Head observations on-chain.

Instances

Instances details
FromJSON HeadObservation Source # 
Instance details

Defined in Hydra.Tx.Observe

ToJSON HeadObservation Source # 
Instance details

Defined in Hydra.Tx.Observe

Generic HeadObservation Source # 
Instance details

Defined in Hydra.Tx.Observe

Associated Types

type Rep HeadObservation :: Type -> Type Source #

Show HeadObservation Source # 
Instance details

Defined in Hydra.Tx.Observe

Eq HeadObservation Source # 
Instance details

Defined in Hydra.Tx.Observe

type Rep HeadObservation Source # 
Instance details

Defined in Hydra.Tx.Observe

type Rep HeadObservation = D1 ('MetaData "HeadObservation" "Hydra.Tx.Observe" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (((C1 ('MetaCons "NoHeadTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Init" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 InitObservation))) :+: (C1 ('MetaCons "Deposit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DepositObservation)) :+: (C1 ('MetaCons "Recover" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RecoverObservation)) :+: C1 ('MetaCons "Increment" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IncrementObservation))))) :+: ((C1 ('MetaCons "Decrement" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 DecrementObservation)) :+: (C1 ('MetaCons "Close" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CloseObservation)) :+: C1 ('MetaCons "Contest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContestObservation)))) :+: (C1 ('MetaCons "PartialFanout" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 PartialFanoutObservation)) :+: (C1 ('MetaCons "Fanout" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FanoutObservation)) :+: C1 ('MetaCons "FinalPartialFanout" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FanoutObservation))))))

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.

Instances

Instances details
FromJSON InitObservation Source # 
Instance details

Defined in Hydra.Tx.Init

ToJSON InitObservation Source # 
Instance details

Defined in Hydra.Tx.Init

Generic InitObservation Source # 
Instance details

Defined in Hydra.Tx.Init

Associated Types

type Rep InitObservation :: Type -> Type Source #

Show InitObservation Source # 
Instance details

Defined in Hydra.Tx.Init

Eq InitObservation Source # 
Instance details

Defined in Hydra.Tx.Init

type Rep InitObservation Source # 
Instance details

Defined in Hydra.Tx.Init

type Rep InitObservation = D1 ('MetaData "InitObservation" "Hydra.Tx.Init" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "InitObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed)) :*: (S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "participants") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [OnChainId]))))

data NotAnInitReason Source #

Instances

Instances details
ToJSON NotAnInitReason Source # 
Instance details

Defined in Hydra.Tx.Init

Generic NotAnInitReason Source # 
Instance details

Defined in Hydra.Tx.Init

Associated Types

type Rep NotAnInitReason :: Type -> Type Source #

Show NotAnInitReason Source # 
Instance details

Defined in Hydra.Tx.Init

Eq NotAnInitReason Source # 
Instance details

Defined in Hydra.Tx.Init

type Rep NotAnInitReason Source # 
Instance details

Defined in Hydra.Tx.Init

type Rep NotAnInitReason = D1 ('MetaData "NotAnInitReason" "Hydra.Tx.Init" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (((C1 ('MetaCons "NoHeadOutput" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotAHeadDatum" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "InvalidPartyInDatum" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InvalidContestationPeriodInDatum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))) :+: ((C1 ('MetaCons "InvalidDepositPeriodInDatum" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: C1 ('MetaCons "NoSTFound" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NotAHeadPolicy" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoTokensMinted" 'PrefixI 'False) (U1 :: Type -> Type))))

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 #

Instances

Instances details
FromJSON DecrementObservation Source # 
Instance details

Defined in Hydra.Tx.Decrement

ToJSON DecrementObservation Source # 
Instance details

Defined in Hydra.Tx.Decrement

Generic DecrementObservation Source # 
Instance details

Defined in Hydra.Tx.Decrement

Associated Types

type Rep DecrementObservation :: Type -> Type Source #

Show DecrementObservation Source # 
Instance details

Defined in Hydra.Tx.Decrement

Eq DecrementObservation Source # 
Instance details

Defined in Hydra.Tx.Decrement

type Rep DecrementObservation Source # 
Instance details

Defined in Hydra.Tx.Decrement

type Rep DecrementObservation = D1 ('MetaData "DecrementObservation" "Hydra.Tx.Decrement" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "DecrementObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "newVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion)) :*: (S1 ('MetaSel ('Just "distributedUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO) :*: (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot Tx)))))))

data DepositObservation Source #

Constructors

DepositObservation 

Fields

Instances

Instances details
FromJSON DepositObservation Source # 
Instance details

Defined in Hydra.Tx.Deposit

ToJSON DepositObservation Source # 
Instance details

Defined in Hydra.Tx.Deposit

Generic DepositObservation Source # 
Instance details

Defined in Hydra.Tx.Deposit

Associated Types

type Rep DepositObservation :: Type -> Type Source #

Show DepositObservation Source # 
Instance details

Defined in Hydra.Tx.Deposit

Eq DepositObservation Source # 
Instance details

Defined in Hydra.Tx.Deposit

type Rep DepositObservation Source # 
Instance details

Defined in Hydra.Tx.Deposit

type Rep DepositObservation = D1 ('MetaData "DepositObservation" "Hydra.Tx.Deposit" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "DepositObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxId)) :*: (S1 ('MetaSel ('Just "deposited") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO) :*: (S1 ('MetaSel ('Just "created") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SlotNo) :*: S1 ('MetaSel ('Just "deadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime)))))

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 #

Instances

Instances details
FromJSON IncrementObservation Source # 
Instance details

Defined in Hydra.Tx.Increment

ToJSON IncrementObservation Source # 
Instance details

Defined in Hydra.Tx.Increment

Generic IncrementObservation Source # 
Instance details

Defined in Hydra.Tx.Increment

Associated Types

type Rep IncrementObservation :: Type -> Type Source #

Show IncrementObservation Source # 
Instance details

Defined in Hydra.Tx.Increment

Eq IncrementObservation Source # 
Instance details

Defined in Hydra.Tx.Increment

type Rep IncrementObservation Source # 
Instance details

Defined in Hydra.Tx.Increment

type Rep IncrementObservation = D1 ('MetaData "IncrementObservation" "Hydra.Tx.Increment" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "IncrementObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "newVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxId))) :*: (S1 ('MetaSel ('Just "deposited") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO) :*: (S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot Tx)))))))

observeIncrementTx :: NetworkId -> UTxO -> Tx -> Maybe IncrementObservation Source #

data RecoverObservation Source #

Constructors

RecoverObservation 

Fields

Instances

Instances details
FromJSON RecoverObservation Source # 
Instance details

Defined in Hydra.Tx.Recover

ToJSON RecoverObservation Source # 
Instance details

Defined in Hydra.Tx.Recover

Generic RecoverObservation Source # 
Instance details

Defined in Hydra.Tx.Recover

Associated Types

type Rep RecoverObservation :: Type -> Type Source #

Show RecoverObservation Source # 
Instance details

Defined in Hydra.Tx.Recover

Eq RecoverObservation Source # 
Instance details

Defined in Hydra.Tx.Recover

type Rep RecoverObservation Source # 
Instance details

Defined in Hydra.Tx.Recover

type Rep RecoverObservation = D1 ('MetaData "RecoverObservation" "Hydra.Tx.Recover" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "RecoverObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "recoveredTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxId) :*: S1 ('MetaSel ('Just "recoveredUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO))))

observeRecoverTx :: NetworkId -> UTxO -> Tx -> Maybe RecoverObservation Source #

data CloseObservation Source #

Constructors

CloseObservation 

Fields

Instances

Instances details
FromJSON CloseObservation Source # 
Instance details

Defined in Hydra.Tx.Close

ToJSON CloseObservation Source # 
Instance details

Defined in Hydra.Tx.Close

Generic CloseObservation Source # 
Instance details

Defined in Hydra.Tx.Close

Associated Types

type Rep CloseObservation :: Type -> Type Source #

Show CloseObservation Source # 
Instance details

Defined in Hydra.Tx.Close

Eq CloseObservation Source # 
Instance details

Defined in Hydra.Tx.Close

type Rep CloseObservation Source # 
Instance details

Defined in Hydra.Tx.Close

type Rep CloseObservation = D1 ('MetaData "CloseObservation" "Hydra.Tx.Close" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "CloseObservation" '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) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot Tx))))))

observeCloseTx Source #

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

Instances details
FromJSON ContestObservation Source # 
Instance details

Defined in Hydra.Tx.Contest

ToJSON ContestObservation Source # 
Instance details

Defined in Hydra.Tx.Contest

Generic ContestObservation Source # 
Instance details

Defined in Hydra.Tx.Contest

Associated Types

type Rep ContestObservation :: Type -> Type Source #

Show ContestObservation Source # 
Instance details

Defined in Hydra.Tx.Contest

Eq ContestObservation Source # 
Instance details

Defined in Hydra.Tx.Contest

type Rep ContestObservation Source # 
Instance details

Defined in Hydra.Tx.Contest

type Rep ContestObservation = D1 ('MetaData "ContestObservation" "Hydra.Tx.Contest" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "ContestObservation" '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) :*: (S1 ('MetaSel ('Just "contesters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [PubKeyHash]) :*: S1 ('MetaSel ('Just "signatures") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (MultiSignature (Snapshot Tx)))))))

observeContestTx Source #

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

Instances details
FromJSON FanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

ToJSON FanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

Generic FanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

Associated Types

type Rep FanoutObservation :: Type -> Type Source #

Show FanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

Eq FanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

type Rep FanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

type Rep FanoutObservation = D1 ('MetaData "FanoutObservation" "Hydra.Tx.Fanout" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "FanoutObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "fanoutUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO)))

data PartialFanoutObservation Source #

Constructors

PartialFanoutObservation 

Fields

Instances

Instances details
FromJSON PartialFanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

ToJSON PartialFanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

Generic PartialFanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

Associated Types

type Rep PartialFanoutObservation :: Type -> Type Source #

Show PartialFanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

Eq PartialFanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

type Rep PartialFanoutObservation Source # 
Instance details

Defined in Hydra.Tx.Fanout

type Rep PartialFanoutObservation = D1 ('MetaData "PartialFanoutObservation" "Hydra.Tx.Fanout" "hydra-tx-2.4.1-6u9wd83eS2xF3WS9TuJN93" 'False) (C1 ('MetaCons "PartialFanoutObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "distributedOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO)))

observeFanoutTx Source #

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.