Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
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
- type UTxOWithScript = (TxIn, TxOut CtxUTxO, HashableScriptData)
- newtype UTxOHash = UTxOHash ByteString
- data InitialThreadOutput = InitialThreadOutput {
- initialThreadUTxO :: (TxIn, TxOut CtxUTxO)
- initialContestationPeriod :: ContestationPeriod
- initialParties :: [Party]
- getHydraHeadV1TxName :: Tx -> Maybe Text
- data HeadObservation
- observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation
- data InitObservation = InitObservation {
- initialThreadUTxO :: (TxIn, TxOut CtxUTxO)
- initials :: [(TxIn, TxOut CtxUTxO)]
- headId :: HeadId
- seedTxIn :: TxIn
- contestationPeriod :: ContestationPeriod
- parties :: [Party]
- participants :: [OnChainId]
- data NotAnInitReason
- observeInitTx :: Tx -> Either NotAnInitReason InitObservation
- data CommitObservation = CommitObservation {
- commitOutput :: (TxIn, TxOut CtxUTxO)
- party :: Party
- committed :: UTxO
- headId :: HeadId
- observeCommitTx :: NetworkId -> UTxO -> Tx -> Maybe CommitObservation
- data CollectComObservation = CollectComObservation {
- threadOutput :: OpenThreadOutput
- headId :: HeadId
- utxoHash :: UTxOHash
- observeCollectComTx :: UTxO -> Tx -> Maybe CollectComObservation
- data DecrementObservation = DecrementObservation {
- headId :: HeadId
- newVersion :: SnapshotVersion
- distributedOutputs :: [TxOut CtxUTxO]
- observeDecrementTx :: UTxO -> Tx -> Maybe DecrementObservation
- data CloseObservation = CloseObservation {
- threadOutput :: ClosedThreadOutput
- headId :: HeadId
- snapshotNumber :: SnapshotNumber
- observeCloseTx :: UTxO -> Tx -> Maybe CloseObservation
- data ContestObservation = ContestObservation {
- contestedThreadOutput :: (TxIn, TxOut CtxUTxO)
- headId :: HeadId
- snapshotNumber :: SnapshotNumber
- contestationDeadline :: UTCTime
- contesters :: [PubKeyHash]
- observeContestTx :: UTxO -> Tx -> Maybe ContestObservation
- newtype FanoutObservation = FanoutObservation {
- headId :: HeadId
- observeFanoutTx :: UTxO -> Tx -> Maybe FanoutObservation
- newtype AbortObservation = AbortObservation {
- headId :: HeadId
- observeAbortTx :: UTxO -> Tx -> Maybe AbortObservation
- currencySymbolToHeadId :: MonadFail m => CurrencySymbol -> m HeadId
- headIdToPolicyId :: MonadFail m => HeadId -> m PolicyId
- headSeedToTxIn :: MonadFail m => HeadSeed -> m TxIn
- txInToHeadSeed :: TxIn -> HeadSeed
- findHeadAssetId :: TxOut ctx -> Maybe (PolicyId, AssetName)
- findStateToken :: TxOut ctx -> Maybe HeadId
Documentation
type UTxOWithScript = (TxIn, TxOut CtxUTxO, HashableScriptData) Source #
Needed on-chain data to create Head transactions.
Instances
Arbitrary UTxOHash Source # | |
FromJSON UTxOHash Source # | |
Defined in Hydra.Chain.Direct.Tx parseJSON :: Value -> Parser UTxOHash parseJSONList :: Value -> Parser [UTxOHash] | |
ToJSON UTxOHash Source # | |
Defined in Hydra.Chain.Direct.Tx toEncoding :: UTxOHash -> Encoding toJSONList :: [UTxOHash] -> Value toEncodingList :: [UTxOHash] -> Encoding | |
Generic UTxOHash Source # | |
Show UTxOHash Source # | |
Eq UTxOHash Source # | |
type Rep UTxOHash Source # | |
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.
InitialThreadOutput | |
|
Instances
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
observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation Source #
Observe any Hydra head transaction.
data InitObservation Source #
Data which can be observed from an initTx
.
InitObservation | |
|
Instances
data NotAnInitReason Source #
Instances
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.
CommitObservation | |
|
Instances
:: 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 #
CollectComObservation | |
|
Instances
Arbitrary CollectComObservation Source # | |
Defined in Hydra.Chain.Direct.Tx | |
Generic CollectComObservation Source # | |
Defined in Hydra.Chain.Direct.Tx | |
Show CollectComObservation Source # | |
Defined in Hydra.Chain.Direct.Tx | |
Eq CollectComObservation Source # | |
Defined in Hydra.Chain.Direct.Tx | |
type Rep CollectComObservation Source # | |
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)))) |
:: 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 #
DecrementObservation | |
|
Instances
observeDecrementTx :: UTxO -> Tx -> Maybe DecrementObservation Source #
data CloseObservation Source #
CloseObservation | |
|
Instances
:: 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 #
ContestObservation | |
|
Instances
:: 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 #
FanoutObservation | |
|
Instances
Arbitrary FanoutObservation Source # | |
Defined in Hydra.Chain.Direct.Tx arbitrary :: Gen FanoutObservation shrink :: FanoutObservation -> [FanoutObservation] | |
Generic FanoutObservation Source # | |
Defined in Hydra.Chain.Direct.Tx from :: FanoutObservation -> Rep FanoutObservation x Source # to :: Rep FanoutObservation x -> FanoutObservation Source # | |
Show FanoutObservation Source # | |
Defined in Hydra.Chain.Direct.Tx | |
Eq FanoutObservation Source # | |
Defined in Hydra.Chain.Direct.Tx (==) :: FanoutObservation -> FanoutObservation -> Bool Source # (/=) :: FanoutObservation -> FanoutObservation -> Bool Source # | |
type Rep FanoutObservation Source # | |
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))) |
:: 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 #
AbortObservation | |
|
Instances
Arbitrary AbortObservation Source # | |
Defined in Hydra.Chain.Direct.Tx arbitrary :: Gen AbortObservation shrink :: AbortObservation -> [AbortObservation] | |
Generic AbortObservation Source # | |
Defined in Hydra.Chain.Direct.Tx from :: AbortObservation -> Rep AbortObservation x Source # to :: Rep AbortObservation x -> AbortObservation Source # | |
Show AbortObservation Source # | |
Defined in Hydra.Chain.Direct.Tx | |
Eq AbortObservation Source # | |
Defined in Hydra.Chain.Direct.Tx (==) :: AbortObservation -> AbortObservation -> Bool Source # (/=) :: AbortObservation -> AbortObservation -> Bool Source # | |
type Rep AbortObservation Source # | |
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))) |
:: 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
.