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
- newtype AbortObservation = AbortObservation {
- headId :: HeadId
- data CloseObservation = CloseObservation {
- threadOutput :: ClosedThreadOutput
- headId :: HeadId
- snapshotNumber :: SnapshotNumber
- data CollectComObservation = CollectComObservation {
- threadOutput :: OpenThreadOutput
- headId :: HeadId
- utxoHash :: UTxOHash
- data CommitObservation = CommitObservation {
- commitOutput :: (TxIn, TxOut CtxUTxO)
- party :: Party
- committed :: UTxO
- headId :: HeadId
- data ContestObservation = ContestObservation {
- contestedThreadOutput :: (TxIn, TxOut CtxUTxO)
- headId :: HeadId
- snapshotNumber :: SnapshotNumber
- contestationDeadline :: UTCTime
- contesters :: [PubKeyHash]
- data DecrementObservation = DecrementObservation {
- headId :: HeadId
- newVersion :: SnapshotVersion
- distributedOutputs :: [TxOut CtxUTxO]
- newtype FanoutObservation = FanoutObservation {
- headId :: HeadId
- data HeadObservation
- = NoHeadTx
- | Init InitObservation
- | Abort AbortObservation
- | Commit CommitObservation
- | CollectCom CollectComObservation
- | Deposit DepositObservation
- | Recover RecoverObservation
- | Increment IncrementObservation
- | Decrement DecrementObservation
- | Close CloseObservation
- | Contest ContestObservation
- | Fanout FanoutObservation
- data IncrementObservation = IncrementObservation {
- headId :: HeadId
- newVersion :: SnapshotVersion
- depositTxId :: TxId
- data InitObservation = InitObservation {
- initialThreadUTxO :: (TxIn, TxOut CtxUTxO)
- initials :: [(TxIn, TxOut CtxUTxO)]
- headId :: HeadId
- seedTxIn :: TxIn
- contestationPeriod :: ContestationPeriod
- parties :: [Party]
- participants :: [OnChainId]
- data InitialThreadOutput = InitialThreadOutput {
- initialThreadUTxO :: (TxIn, TxOut CtxUTxO)
- initialContestationPeriod :: ContestationPeriod
- initialParties :: [Party]
- data NotAnInitReason
- newtype UTxOHash = UTxOHash ByteString
- type UTxOWithScript = (TxIn, TxOut CtxUTxO, HashableScriptData)
- headSeedToTxIn :: MonadFail m => HeadSeed -> m TxIn
- observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation
- txInToHeadSeed :: TxIn -> HeadSeed
- headIdToPolicyId :: MonadFail m => HeadId -> m PolicyId
- observeCloseTx :: UTxO -> Tx -> Maybe CloseObservation
- observeCollectComTx :: UTxO -> Tx -> Maybe CollectComObservation
- observeCommitTx :: NetworkId -> UTxO -> Tx -> Maybe CommitObservation
- observeInitTx :: Tx -> Either NotAnInitReason InitObservation
- getHydraHeadV1TxName :: Tx -> Maybe Text
- observeAbortTx :: UTxO -> Tx -> Maybe AbortObservation
- observeIncrementTx :: UTxO -> Tx -> Maybe IncrementObservation
- observeDecrementTx :: UTxO -> Tx -> Maybe DecrementObservation
- observeContestTx :: UTxO -> Tx -> Maybe ContestObservation
- observeFanoutTx :: UTxO -> Tx -> Maybe FanoutObservation
- findStateToken :: TxOut ctx -> Maybe HeadId
- currencySymbolToHeadId :: MonadFail m => CurrencySymbol -> m HeadId
- findHeadAssetId :: TxOut ctx -> Maybe (PolicyId, AssetName)
Documentation
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.20.0-GJlHI5giGamBfggh7PdYBV" 'True) (C1 ('MetaCons "AbortObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId))) |
data CloseObservation Source #
CloseObservation | |
|
Instances
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.20.0-GJlHI5giGamBfggh7PdYBV" '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)))) |
data CommitObservation Source #
Full observation of a commit transaction.
CommitObservation | |
|
Instances
data ContestObservation Source #
ContestObservation | |
|
Instances
data DecrementObservation Source #
DecrementObservation | |
|
Instances
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.20.0-GJlHI5giGamBfggh7PdYBV" 'True) (C1 ('MetaCons "FanoutObservation" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId))) |
data HeadObservation Source #
Generalised type for arbitrary Head observations on-chain.
Instances
data IncrementObservation Source #
IncrementObservation | |
|
Instances
data InitObservation Source #
Data which can be observed from an initTx
.
InitObservation | |
|
Instances
data InitialThreadOutput Source #
Representation of the Head output after an Init transaction.
InitialThreadOutput | |
|
Instances
data NotAnInitReason Source #
Instances
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.20.0-GJlHI5giGamBfggh7PdYBV" 'True) (C1 ('MetaCons "UTxOHash" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ByteString))) |
type UTxOWithScript = (TxIn, TxOut CtxUTxO, HashableScriptData) Source #
Needed on-chain data to create Head transactions.
headSeedToTxIn :: MonadFail m => HeadSeed -> m TxIn Source #
observeHeadTx :: NetworkId -> UTxO -> Tx -> HeadObservation Source #
Observe any Hydra head transaction.
txInToHeadSeed :: TxIn -> HeadSeed Source #
headIdToPolicyId :: MonadFail m => HeadId -> m PolicyId Source #
:: 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.
:: 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.
:: 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).
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).
getHydraHeadV1TxName :: Tx -> Maybe Text Source #
Get the metadata entry to identify Hydra transactions (for informational purposes).
:: 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.
observeIncrementTx :: UTxO -> Tx -> Maybe IncrementObservation Source #
observeDecrementTx :: UTxO -> Tx -> Maybe DecrementObservation Source #
:: 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.
:: 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.
findStateToken :: TxOut ctx -> Maybe HeadId Source #
Find (if it exists) the head identifier contained in given TxOut
.
currencySymbolToHeadId :: MonadFail m => CurrencySymbol -> m HeadId Source #
findHeadAssetId :: TxOut ctx -> Maybe (PolicyId, AssetName) Source #