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

Hydra.Chain.Direct.Tx

Description

Smart constructors for creating Hydra protocol transactions to be used in the Direct way of talking to the main-chain.

This module also encapsulates the transaction format used when talking to the cardano-node, which is currently different from the Cardano, thus we have not yet "reached" isomorphism.

Synopsis

Documentation

type UTxOWithScript = (TxIn, TxOut CtxUTxO, HashableScriptData) Source #

Needed on-chain data to create Head transactions.

newtype UTxOHash Source #

Constructors

UTxOHash ByteString 

Instances

Instances details
Arbitrary UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

FromJSON UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Methods

parseJSON :: Value -> Parser UTxOHash

parseJSONList :: Value -> Parser [UTxOHash]

omittedField :: Maybe UTxOHash

ToJSON UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Methods

toJSON :: UTxOHash -> Value

toEncoding :: UTxOHash -> Encoding

toJSONList :: [UTxOHash] -> Value

toEncodingList :: [UTxOHash] -> Encoding

omitField :: UTxOHash -> Bool

Generic UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep UTxOHash :: Type -> Type Source #

Show UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep UTxOHash Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep UTxOHash = D1 ('MetaData "UTxOHash" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'True) (C1 ('MetaCons "UTxOHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString)))

data InitialThreadOutput Source #

Representation of the Head output after an Init transaction.

Constructors

InitialThreadOutput 

Fields

Instances

Instances details
Arbitrary InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

FromJSON InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

ToJSON InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep InitialThreadOutput :: Type -> Type Source #

Show InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep InitialThreadOutput Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep InitialThreadOutput = D1 ('MetaData "InitialThreadOutput" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "InitialThreadOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "initialThreadUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIn, TxOut CtxUTxO)) :*: (S1 ('MetaSel ('Just "initialContestationPeriod") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContestationPeriod) :*: S1 ('MetaSel ('Just "initialParties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party]))))

getHydraHeadV1TxName :: Tx -> Maybe Text Source #

Get the metadata entry to identify Hydra transactions (for informational purposes).

Observe Hydra Head transactions

data HeadObservation Source #

Generalised type for arbitrary Head observations on-chain.

Instances

Instances details
Arbitrary HeadObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic HeadObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep HeadObservation :: Type -> Type Source #

Show HeadObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq HeadObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep HeadObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep HeadObservation = D1 ('MetaData "HeadObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" '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 "Abort" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 AbortObservation)) :+: C1 ('MetaCons "Commit" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CommitObservation)))) :+: ((C1 ('MetaCons "CollectCom" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 CollectComObservation)) :+: 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 "Fanout" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 FanoutObservation))))))

observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation Source #

Observe any Hydra head transaction.

data InitObservation Source #

Data which can be observed from an initTx.

Constructors

InitObservation 

Fields

Instances

Instances details
Arbitrary InitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic InitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep InitObservation :: Type -> Type Source #

Show InitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq InitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep InitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep InitObservation = D1 ('MetaData "InitObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "InitObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "initialThreadUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIn, TxOut CtxUTxO)) :*: (S1 ('MetaSel ('Just "initials") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [(TxIn, TxOut CtxUTxO)]) :*: S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId))) :*: ((S1 ('MetaSel ('Just "seedTxIn") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxIn) :*: 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 NotAnInitReason Source #

Instances

Instances details
Arbitrary NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

FromJSON NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

ToJSON NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep NotAnInitReason :: Type -> Type Source #

Show NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep NotAnInitReason Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep NotAnInitReason = D1 ('MetaData "NotAnInitReason" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) ((C1 ('MetaCons "NoHeadOutput" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotAHeadDatum" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NoSTFound" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NotAHeadPolicy" 'PrefixI 'False) (U1 :: Type -> Type)))

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 CommitObservation Source #

Full observation of a commit transaction.

Constructors

CommitObservation 

Fields

Instances

Instances details
Arbitrary CommitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic CommitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep CommitObservation :: Type -> Type Source #

Show CommitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq CommitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep CommitObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep CommitObservation = D1 ('MetaData "CommitObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "CommitObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "commitOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIn, TxOut CtxUTxO)) :*: S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party)) :*: (S1 ('MetaSel ('Just "committed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxO) :*: S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId))))

observeCommitTx Source #

Arguments

:: NetworkId 
-> UTxO

A UTxO set to lookup tx inputs. Should at least contain the input spending from νInitial.

-> Tx 
-> Maybe CommitObservation 

Identify a commit tx by:

  • Check that its spending from the init validator,
  • Find the outputs which pays to the commit validator,
  • Using the datum of that output, deserialize the committed output,
  • Reconstruct the committed UTxO from both values (tx input and output).

data CollectComObservation Source #

Constructors

CollectComObservation 

Fields

Instances

Instances details
Arbitrary CollectComObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic CollectComObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep CollectComObservation :: Type -> Type Source #

Show CollectComObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq CollectComObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep CollectComObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep CollectComObservation = D1 ('MetaData "CollectComObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "CollectComObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "threadOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 OpenThreadOutput) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "utxoHash") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTxOHash))))

observeCollectComTx Source #

Arguments

:: UTxO

A UTxO set to lookup tx inputs

-> Tx 
-> Maybe CollectComObservation 

Identify a collectCom tx by lookup up the input spending the Head output and decoding its redeemer.

data DecrementObservation Source #

Constructors

DecrementObservation 

Fields

Instances

Instances details
Arbitrary DecrementObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic DecrementObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep DecrementObservation :: Type -> Type Source #

Show DecrementObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq DecrementObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep DecrementObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep DecrementObservation = D1 ('MetaData "DecrementObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" '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 "distributedOutputs") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [TxOut CtxUTxO]))))

data CloseObservation Source #

Constructors

CloseObservation 

Fields

Instances

Instances details
Arbitrary CloseObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic CloseObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep CloseObservation :: Type -> Type Source #

Show CloseObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq CloseObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep CloseObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep CloseObservation = D1 ('MetaData "CloseObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "CloseObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "threadOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ClosedThreadOutput) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "snapshotNumber") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotNumber))))

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
Arbitrary ContestObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic ContestObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep ContestObservation :: Type -> Type Source #

Show ContestObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq ContestObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep ContestObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep ContestObservation = D1 ('MetaData "ContestObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'False) (C1 ('MetaCons "ContestObservation" 'PrefixI 'True) ((S1 ('MetaSel ('Just "contestedThreadOutput") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIn, TxOut CtxUTxO)) :*: 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])))))

observeContestTx Source #

Arguments

:: UTxO

A UTxO set to lookup tx inputs

-> Tx 
-> Maybe ContestObservation 

Identify a close tx by lookup up the input spending the Head output and decoding its redeemer.

newtype FanoutObservation Source #

Constructors

FanoutObservation 

Fields

Instances

Instances details
Arbitrary FanoutObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic FanoutObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep FanoutObservation :: Type -> Type Source #

Show FanoutObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq FanoutObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep FanoutObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep FanoutObservation = D1 ('MetaData "FanoutObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'True) (C1 ('MetaCons "FanoutObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)))

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.

newtype AbortObservation Source #

Constructors

AbortObservation 

Fields

Instances

Instances details
Arbitrary AbortObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Generic AbortObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Associated Types

type Rep AbortObservation :: Type -> Type Source #

Show AbortObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

Eq AbortObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep AbortObservation Source # 
Instance details

Defined in Hydra.Chain.Direct.Tx

type Rep AbortObservation = D1 ('MetaData "AbortObservation" "Hydra.Chain.Direct.Tx" "hydra-node-0.19.0-6Z4E5vp1s1XJuLOmmEVMTw" 'True) (C1 ('MetaCons "AbortObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)))

observeAbortTx Source #

Arguments

:: UTxO

A UTxO set to lookup tx inputs

-> Tx 
-> Maybe AbortObservation 

Identify an abort tx by looking up the input spending the Head output and decoding its redeemer.

Cardano specific identifiers

currencySymbolToHeadId :: MonadFail m => CurrencySymbol -> m HeadId Source #

headIdToPolicyId :: MonadFail m => HeadId -> m PolicyId Source #

headSeedToTxIn :: MonadFail m => HeadSeed -> m TxIn Source #

txInToHeadSeed :: TxIn -> HeadSeed Source #

Helpers

findHeadAssetId :: TxOut ctx -> Maybe (PolicyId, AssetName) Source #

findStateToken :: TxOut ctx -> Maybe HeadId Source #

Find (if it exists) the head identifier contained in given TxOut.