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

Hydra.Chain

Description

Specifies the Head-Chain Interaction part of the protocol

Incoming and outgoing on-chain transactions are modelled respectively as OnChainTx and PostChainTx which are data type that abstracts away the details of the structure of the transaction.

Synopsis

Documentation

maxMainnetLovelace :: Coin Source #

Hardcoded limit for commit tx on mainnet

maximumNumberOfParties :: Int Source #

Hardcoded limit for maximum number of parties in a head protocol The value is obtained from calculating the costs of running the scripts and on-chan validators (see computeCollectComCost computeAbortCost). A too high enough number would be detected by property and acceptance tests.

data PostChainTx tx Source #

Data type used to post transactions on chain. It holds everything to construct corresponding Head protocol transactions.

Constructors

InitTx 

Fields

AbortTx 

Fields

CollectComTx 

Fields

IncrementTx 

Fields

RecoverTx 

Fields

DecrementTx 

Fields

CloseTx 

Fields

ContestTx 

Fields

FanoutTx 

Fields

Instances

Instances details
ArbitraryIsTx tx => Arbitrary (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

arbitrary :: Gen (PostChainTx tx)

shrink :: PostChainTx tx -> [PostChainTx tx]

IsTx tx => FromJSON (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (PostChainTx tx)

parseJSONList :: Value -> Parser [PostChainTx tx]

omittedField :: Maybe (PostChainTx tx)

IsTx tx => ToJSON (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toJSON :: PostChainTx tx -> Value

toEncoding :: PostChainTx tx -> Encoding

toJSONList :: [PostChainTx tx] -> Value

toEncodingList :: [PostChainTx tx] -> Encoding

omitField :: PostChainTx tx -> Bool

Generic (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

type Rep (PostChainTx tx) :: Type -> Type Source #

Methods

from :: PostChainTx tx -> Rep (PostChainTx tx) x Source #

to :: Rep (PostChainTx tx) x -> PostChainTx tx Source #

IsTx tx => Show (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

IsTx tx => Eq (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (PostChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (PostChainTx tx) = D1 ('MetaData "PostChainTx" "Hydra.Chain" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (((C1 ('MetaCons "InitTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "participants") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [OnChainId]) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters)) :+: C1 ('MetaCons "AbortTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed))) :+: (C1 ('MetaCons "CollectComTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters))) :+: C1 ('MetaCons "IncrementTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters)) :*: (S1 ('MetaSel ('Just "incrementingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx)) :*: S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx)))))) :+: ((C1 ('MetaCons "RecoverTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "recoverTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx)) :*: S1 ('MetaSel ('Just "deadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainSlot))) :+: C1 ('MetaCons "DecrementTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "decrementingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx))))) :+: (C1 ('MetaCons "CloseTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters)) :*: (S1 ('MetaSel ('Just "openVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "closingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx)))) :+: (C1 ('MetaCons "ContestTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters)) :*: (S1 ('MetaSel ('Just "openVersion") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 SnapshotVersion) :*: S1 ('MetaSel ('Just "contestingSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx)))) :+: C1 ('MetaCons "FanoutTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: S1 ('MetaSel ('Just "utxoToDecommit") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Maybe (UTxOType tx)))) :*: (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed) :*: S1 ('MetaSel ('Just "contestationDeadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime)))))))

data OnChainTx tx Source #

Describes transactions as seen on chain. Holds as minimal information as possible to simplify observing the chain.

Constructors

OnInitTx 

Fields

OnCommitTx 

Fields

OnAbortTx 

Fields

OnCollectComTx 

Fields

OnDepositTx 

Fields

OnRecoverTx 

Fields

OnIncrementTx 

Fields

OnDecrementTx 

Fields

OnCloseTx 

Fields

OnContestTx 

Fields

OnFanoutTx 

Fields

Instances

Instances details
ArbitraryIsTx tx => Arbitrary (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

arbitrary :: Gen (OnChainTx tx)

shrink :: OnChainTx tx -> [OnChainTx tx]

IsTx tx => FromJSON (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (OnChainTx tx)

parseJSONList :: Value -> Parser [OnChainTx tx]

omittedField :: Maybe (OnChainTx tx)

IsTx tx => ToJSON (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toJSON :: OnChainTx tx -> Value

toEncoding :: OnChainTx tx -> Encoding

toJSONList :: [OnChainTx tx] -> Value

toEncodingList :: [OnChainTx tx] -> Encoding

omitField :: OnChainTx tx -> Bool

Generic (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

type Rep (OnChainTx tx) :: Type -> Type Source #

Methods

from :: OnChainTx tx -> Rep (OnChainTx tx) x Source #

to :: Rep (OnChainTx tx) x -> OnChainTx tx Source #

IsTx tx => Show (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

IsTx tx => Eq (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

(==) :: OnChainTx tx -> OnChainTx tx -> Bool Source #

(/=) :: OnChainTx tx -> OnChainTx tx -> Bool Source #

type Rep (OnChainTx tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (OnChainTx tx) = D1 ('MetaData "OnChainTx" "Hydra.Chain" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (((C1 ('MetaCons "OnInitTx" '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]))) :+: C1 ('MetaCons "OnCommitTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "party") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Party) :*: S1 ('MetaSel ('Just "committed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))))) :+: (C1 ('MetaCons "OnAbortTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)) :+: (C1 ('MetaCons "OnCollectComTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)) :+: C1 ('MetaCons "OnDepositTx" 'PrefixI 'True) ((S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "deposited") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :*: (S1 ('MetaSel ('Just "depositTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx)) :*: S1 ('MetaSel ('Just "deadline") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime)))))) :+: ((C1 ('MetaCons "OnRecoverTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: S1 ('MetaSel ('Just "recoveredTxId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (TxIdType tx))) :+: (C1 ('MetaCons "OnIncrementTx" '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 (TxIdType tx)))) :+: C1 ('MetaCons "OnDecrementTx" '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 [TxOutType tx]))))) :+: (C1 ('MetaCons "OnCloseTx" '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))) :+: (C1 ('MetaCons "OnContestTx" '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))) :+: C1 ('MetaCons "OnFanoutTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId))))))

data PostTxError tx Source #

Exceptions thrown by $sel:postTx:Chain.

Constructors

NoSeedInput 
InvalidSeed 

Fields

InvalidHeadId 

Fields

CannotFindOwnInitial 

Fields

UnsupportedLegacyOutput

Comitting byron addresses is not supported.

Fields

InvalidStateToPost 

Fields

NotEnoughFuel 
NoFuelUTXOFound 
ScriptFailedInWallet

Script execution failed when finalizing a transaction in the wallet. XXX: Ideally we want a cardano-api type with corresonding JSON instance here. But the wallet still uses ledger types and we don't want to copy the conversion from ledger TransactionScriptFailure to the cardano-api ScriptExecutionError type.

InternalWalletError

A generic error happened when finalizing a transction in the wallet.

Fields

FailedToPostTx

An error occurred when submitting a transaction to the cardano-node.

Fields

PlutusValidationFailed

A plutus script failed in a transaction submitted to the cardano-node. NOTE: PlutusDebugInfo does not have much available instances so we put it in Text form but it's lame

CommittedTooMuchADAForMainnet

User tried to commit more than maxMainnetLovelace hardcoded limit on mainnet we keep track of both the hardcoded limit and what the user originally tried to commit

FailedToDraftTxNotInitializing

We can only draft commit tx for the user when in Initializing state

FailedToConstructAbortTx 
FailedToConstructCloseTx 
FailedToConstructContestTx 
FailedToConstructCollectTx 
FailedToConstructDepositTx 
FailedToConstructRecoverTx 
FailedToConstructIncrementTx 
FailedToConstructDecrementTx 
FailedToConstructFanoutTx 

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

arbitrary :: Gen (PostTxError tx)

shrink :: PostTxError tx -> [PostTxError tx]

IsChainState tx => FromJSON (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (PostTxError tx)

parseJSONList :: Value -> Parser [PostTxError tx]

omittedField :: Maybe (PostTxError tx)

IsChainState tx => ToJSON (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toJSON :: PostTxError tx -> Value

toEncoding :: PostTxError tx -> Encoding

toJSONList :: [PostTxError tx] -> Value

toEncodingList :: [PostTxError tx] -> Encoding

omitField :: PostTxError tx -> Bool

IsChainState tx => Exception (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Generic (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

type Rep (PostTxError tx) :: Type -> Type Source #

Methods

from :: PostTxError tx -> Rep (PostTxError tx) x Source #

to :: Rep (PostTxError tx) x -> PostTxError tx Source #

IsChainState tx => Show (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

IsChainState tx => Eq (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (PostTxError tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (PostTxError tx) = D1 ('MetaData "PostTxError" "Hydra.Chain" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) ((((C1 ('MetaCons "NoSeedInput" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "InvalidSeed" 'PrefixI 'True) (S1 ('MetaSel ('Just "headSeed") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadSeed))) :+: (C1 ('MetaCons "InvalidHeadId" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId)) :+: (C1 ('MetaCons "CannotFindOwnInitial" 'PrefixI 'True) (S1 ('MetaSel ('Just "knownUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx))) :+: C1 ('MetaCons "UnsupportedLegacyOutput" 'PrefixI 'True) (S1 ('MetaSel ('Just "byronAddress") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Address ByronAddr)))))) :+: ((C1 ('MetaCons "InvalidStateToPost" 'PrefixI 'True) (S1 ('MetaSel ('Just "txTried") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PostChainTx tx)) :*: S1 ('MetaSel ('Just "chainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))) :+: (C1 ('MetaCons "NotEnoughFuel" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "NoFuelUTXOFound" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "ScriptFailedInWallet" 'PrefixI 'True) (S1 ('MetaSel ('Just "redeemerPtr") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "InternalWalletError" 'PrefixI 'True) (S1 ('MetaSel ('Just "headUTxO") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (UTxOType tx)) :*: (S1 ('MetaSel ('Just "reason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "tx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 tx))) :+: C1 ('MetaCons "FailedToPostTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "failureReason") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))))) :+: (((C1 ('MetaCons "PlutusValidationFailed" 'PrefixI 'True) (S1 ('MetaSel ('Just "plutusFailure") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "plutusDebugInfo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)) :+: (C1 ('MetaCons "CommittedTooMuchADAForMainnet" 'PrefixI 'True) (S1 ('MetaSel ('Just "userCommittedLovelace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Coin) :*: S1 ('MetaSel ('Just "mainnetLimitLovelace") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Coin)) :+: C1 ('MetaCons "FailedToDraftTxNotInitializing" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "FailedToConstructAbortTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FailedToConstructCloseTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FailedToConstructContestTx" 'PrefixI 'False) (U1 :: Type -> Type)))) :+: ((C1 ('MetaCons "FailedToConstructCollectTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FailedToConstructDepositTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FailedToConstructRecoverTx" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "FailedToConstructIncrementTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "FailedToConstructDecrementTx" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "FailedToConstructFanoutTx" 'PrefixI 'False) (U1 :: Type -> Type))))))

data ChainStateHistory tx Source #

A non empty sequence of chain states that can be rolled back. This is expected to be constructed by using the smart constructor initHistory.

Constructors

UnsafeChainStateHistory 

Fields

Instances

Instances details
Arbitrary (ChainStateType tx) => Arbitrary (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

FromJSON (ChainStateType tx) => FromJSON (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (ChainStateHistory tx)

parseJSONList :: Value -> Parser [ChainStateHistory tx]

omittedField :: Maybe (ChainStateHistory tx)

ToJSON (ChainStateType tx) => ToJSON (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toJSON :: ChainStateHistory tx -> Value

toEncoding :: ChainStateHistory tx -> Encoding

toJSONList :: [ChainStateHistory tx] -> Value

toEncodingList :: [ChainStateHistory tx] -> Encoding

omitField :: ChainStateHistory tx -> Bool

Generic (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

type Rep (ChainStateHistory tx) :: Type -> Type Source #

Show (ChainStateType tx) => Show (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

Eq (ChainStateType tx) => Eq (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (ChainStateHistory tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (ChainStateHistory tx) = D1 ('MetaData "ChainStateHistory" "Hydra.Chain" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) (C1 ('MetaCons "UnsafeChainStateHistory" 'PrefixI 'True) (S1 ('MetaSel ('Just "history") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (NonEmpty (ChainStateType tx))) :*: S1 ('MetaSel ('Just "defaultChainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))))

currentState :: ChainStateHistory tx -> ChainStateType tx Source #

pushNewState :: ChainStateType tx -> ChainStateHistory tx -> ChainStateHistory tx Source #

initHistory :: ChainStateType tx -> ChainStateHistory tx Source #

rollbackHistory :: IsChainState tx => ChainSlot -> ChainStateHistory tx -> ChainStateHistory tx Source #

data Chain tx m Source #

Handle to interface with the main chain network

Constructors

Chain 

Fields

  • postTx :: MonadThrow m => PostChainTx tx -> m ()

    Construct and send a transaction to the main chain corresponding to the given PostChainTx description. This function is not expected to block, so it is only responsible for submitting, but it should validate the created transaction against a reasonable local view of the chain and throw an exception when invalid.

    Does at least throw PostTxError.

  • draftCommitTx :: MonadThrow m => HeadId -> CommitBlueprintTx tx -> m (Either (PostTxError tx) tx)

    Create a commit transaction using user provided utxos (zero or many) and a _blueprint_ transaction which spends these outputs. Errors are handled at the call site.

  • draftDepositTx :: MonadThrow m => HeadId -> CommitBlueprintTx tx -> UTCTime -> m (Either (PostTxError tx) tx)

    Create a deposit transaction using user provided utxos (zero or many) , _blueprint_ transaction which spends these outputs and a deadline for their inclusion into L2. Errors are handled at the call site.

  • submitTx :: MonadThrow m => tx -> m ()

    Submit a cardano transaction.

    Throws at least PostTxError.

    XXX: While technically they could be any of 'PostTxError tx', only FailedToPostTx errors are expected here.

data ChainEvent tx Source #

Constructors

Observation

Indicates a head protocol transaction has been observed.

Fields

Rollback 

Fields

Tick

Indicate time has advanced on the chain.

NOTE: While the type does not guarantee that the UTCTime and ChainSlot are consistent the alternative would be provide the means to do the conversion. For Cardano, this would be a systemStart and eraHistory.. which is annoying and if it's kept in the chain layer, it would mean another round trip / state to keep there.

Fields

PostTxError

Event to re-ingest errors from $sel:postTx:Chain for further processing.

Instances

Instances details
(ArbitraryIsTx tx, IsChainState tx) => Arbitrary (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

arbitrary :: Gen (ChainEvent tx)

shrink :: ChainEvent tx -> [ChainEvent tx]

(IsTx tx, IsChainState tx) => FromJSON (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser (ChainEvent tx)

parseJSONList :: Value -> Parser [ChainEvent tx]

omittedField :: Maybe (ChainEvent tx)

(IsTx tx, IsChainState tx) => ToJSON (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

toJSON :: ChainEvent tx -> Value

toEncoding :: ChainEvent tx -> Encoding

toJSONList :: [ChainEvent tx] -> Value

toEncodingList :: [ChainEvent tx] -> Encoding

omitField :: ChainEvent tx -> Bool

Generic (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Associated Types

type Rep (ChainEvent tx) :: Type -> Type Source #

Methods

from :: ChainEvent tx -> Rep (ChainEvent tx) x Source #

to :: Rep (ChainEvent tx) x -> ChainEvent tx Source #

(IsTx tx, IsChainState tx) => Show (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

(IsTx tx, IsChainState tx) => Eq (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

Methods

(==) :: ChainEvent tx -> ChainEvent tx -> Bool Source #

(/=) :: ChainEvent tx -> ChainEvent tx -> Bool Source #

type Rep (ChainEvent tx) Source # 
Instance details

Defined in Hydra.Chain

type Rep (ChainEvent tx) = D1 ('MetaData "ChainEvent" "Hydra.Chain" "hydra-node-0.20.0-GJlHI5giGamBfggh7PdYBV" 'False) ((C1 ('MetaCons "Observation" 'PrefixI 'True) (S1 ('MetaSel ('Just "observedTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (OnChainTx tx)) :*: S1 ('MetaSel ('Just "newChainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx))) :+: C1 ('MetaCons "Rollback" 'PrefixI 'True) (S1 ('MetaSel ('Just "rolledBackChainState") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ChainStateType tx)))) :+: (C1 ('MetaCons "Tick" 'PrefixI 'True) (S1 ('MetaSel ('Just "chainTime") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 UTCTime) :*: S1 ('MetaSel ('Just "chainSlot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainSlot)) :+: C1 ('MetaCons "PostTxError" 'PrefixI 'True) (S1 ('MetaSel ('Just "postChainTx") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PostChainTx tx)) :*: S1 ('MetaSel ('Just "postTxError") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PostTxError tx)))))

type ChainCallback tx m = ChainEvent tx -> m () Source #

A callback indicating a 'ChainEvent tx' happened. Most importantly the Observation of a relevant Hydra transaction.

type ChainComponent tx m a = ChainCallback tx m -> (Chain tx m -> m a) -> m a Source #

A type tying both posting and observing transactions into a single Component.