hydra-node-0.16.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)

data HeadParameters Source #

Contains the head's parameters as established in the initial transaction.

Instances

Instances details
Arbitrary HeadParameters Source # 
Instance details

Defined in Hydra.Chain

FromJSON HeadParameters Source # 
Instance details

Defined in Hydra.Chain

Methods

parseJSON :: Value -> Parser HeadParameters

parseJSONList :: Value -> Parser [HeadParameters]

omittedField :: Maybe HeadParameters

ToJSON HeadParameters Source # 
Instance details

Defined in Hydra.Chain

Generic HeadParameters Source # 
Instance details

Defined in Hydra.Chain

Associated Types

type Rep HeadParameters :: Type -> Type Source #

Show HeadParameters Source # 
Instance details

Defined in Hydra.Chain

Eq HeadParameters Source # 
Instance details

Defined in Hydra.Chain

type Rep HeadParameters Source # 
Instance details

Defined in Hydra.Chain

type Rep HeadParameters = D1 ('MetaData "HeadParameters" "Hydra.Chain" "hydra-node-0.16.0-C0XGScKIquG5I6dPp21445" 'False) (C1 ('MetaCons "HeadParameters" 'PrefixI 'True) (S1 ('MetaSel ('Just "contestationPeriod") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContestationPeriod) :*: S1 ('MetaSel ('Just "parties") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Party])))

mkHeadParameters :: Environment -> HeadParameters Source #

Make HeadParameters that are consistent with the given Environment.

data PostChainTx tx Source #

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

Instances

Instances details
IsTx 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.16.0-C0XGScKIquG5I6dPp21445" '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 "CloseTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "headId") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadId) :*: (S1 ('MetaSel ('Just "headParameters") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 HeadParameters) :*: S1 ('MetaSel ('Just "confirmedSnapshot") '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 "confirmedSnapshot") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ConfirmedSnapshot tx)))) :+: C1 ('MetaCons "FanoutTx" 'PrefixI 'True) (S1 ('MetaSel ('Just "utxo") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (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.

Instances

Instances details
(Arbitrary tx, Arbitrary (UTxOType 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.16.0-C0XGScKIquG5I6dPp21445" '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 "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

CannotCommitReferenceScript

Comitting reference scripts is not supported right now.

InvalidStateToPost 
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

SpendingNodeUtxoForbidden

Committing UTxO addressed to the internal wallet is forbidden.

FailedToConstructAbortTx 
FailedToConstructCloseTx 
FailedToConstructContestTx 
FailedToConstructCollectTx 
FailedToConstructFanoutTx 

Instances

Instances details
(IsTx tx, Arbitrary (ChainStateType 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.16.0-C0XGScKIquG5I6dPp21445" '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 "CannotCommitReferenceScript" 'PrefixI 'False) (U1 :: Type -> Type) :+: 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 "SpendingNodeUtxoForbidden" '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 "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.

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.16.0-C0XGScKIquG5I6dPp21445" '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))))

class (IsTx tx, Eq (ChainStateType tx), Show (ChainStateType tx), Arbitrary (ChainStateType tx), FromJSON (ChainStateType tx), ToJSON (ChainStateType tx)) => IsChainState tx where Source #

Types that can be used on-chain by the Hydra protocol. XXX: Find a better name for this. Maybe IsChainTx or IsL1Tx?

Associated Types

type ChainStateType tx = c | c -> tx Source #

Types of what to keep as L1 chain state.

Methods

chainStateSlot :: ChainStateType tx -> ChainSlot Source #

Get the chain slot for a chain state. NOTE: For any sequence of a encountered, we assume monotonically increasing slots.

Instances

Instances details
IsChainState Tx Source # 
Instance details

Defined in Hydra.Chain.Direct.State

Associated Types

type ChainStateType Tx = (c :: Type) Source #

IsChainState SimpleTx Source # 
Instance details

Defined in Hydra.Ledger.Simple

Associated Types

type ChainStateType SimpleTx = (c :: Type) 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 -> UTxO' (TxOut CtxUTxO, Witness WitCtxTxIn) -> m (Either (PostTxError Tx) Tx)

    Create a commit transaction using user provided utxos (zero or many) and information to spend from a script. 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.

Rollback 
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.

PostTxError

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

Instances

Instances details
(IsTx 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.16.0-C0XGScKIquG5I6dPp21445" '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.