hydra-node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.Chain.CardanoClient

Description

A basic cardano-node client that can talk to a local cardano-node.

The idea of this module is to provide a Haskell interface on top of cardano-cli's API, using cardano-api types.

Synopsis

Documentation

CardanoClient handle

data CardanoClient Source #

Handle interface for abstract querying of a cardano node.

Constructors

CardanoClient 

Fields

Tx Construction / Submission

submitTransaction Source #

Arguments

:: LocalNodeConnectInfo 
-> Tx

A signed transaction.

-> IO () 

Submit a (signed) transaction to the node.

Throws SubmitTransactionException if submission fails.

data SubmitTransactionException Source #

Exceptions that can occur during a transaction submission.

In principle, we can only encounter an EraMismatch at era boundaries, when we try to submit a "next era" transaction as a "current era" transaction, or vice-versa. Similarly, TxValidationError shouldn't occur given that the transaction was safely constructed through buildTransaction.

Constructors

SubmitEraMismatch EraMismatch 
SubmitTxValidationError TxValidationErrorInCardanoMode 

awaitTransaction Source #

Arguments

:: LocalNodeConnectInfo 
-> Tx

The transaction to watch / await

-> IO UTxO 

Await until the given transaction is visible on-chain. Returns the UTxO set produced by that transaction.

Note that this function loops forever; hence, one probably wants to couple it with a surrounding timeout.

Local state query

data QueryPoint Source #

Describes whether to query at the tip or at a specific point.

Constructors

QueryTip 
QueryAt ChainPoint 

Instances

Instances details
Generic QueryPoint Source # 
Instance details

Defined in Hydra.Chain.CardanoClient

Associated Types

type Rep QueryPoint :: Type -> Type Source #

Show QueryPoint Source # 
Instance details

Defined in Hydra.Chain.CardanoClient

Eq QueryPoint Source # 
Instance details

Defined in Hydra.Chain.CardanoClient

type Rep QueryPoint Source # 
Instance details

Defined in Hydra.Chain.CardanoClient

type Rep QueryPoint = D1 ('MetaData "QueryPoint" "Hydra.Chain.CardanoClient" "hydra-node-2.3.0-1cgalYNmLJQC1YXlYVq7mp" 'False) (C1 ('MetaCons "QueryTip" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "QueryAt" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 ChainPoint)))

queryTip :: LocalNodeConnectInfo -> IO ChainPoint Source #

Query the latest chain point aka "the tip".

querySystemStart :: LocalNodeConnectInfo -> QueryPoint -> IO SystemStart Source #

Query the system start parameter at given point.

Throws at least QueryException if query fails.

queryEraHistory :: LocalNodeConnectInfo -> QueryPoint -> IO EraHistory Source #

Query the era history at given point.

Throws at least QueryException if query fails.

queryProtocolParameters :: LocalNodeConnectInfo -> QueryPoint -> IO (PParams LedgerEra) Source #

Query the protocol parameters at given point.

Throws at least QueryException if query fails.

queryGenesisParameters :: LocalNodeConnectInfo -> QueryPoint -> IO (GenesisParameters ShelleyEra) Source #

Query GenesisParameters at a given point.

Throws at least QueryException if query fails.

queryBlockTime :: LocalNodeConnectInfo -> QueryPoint -> IO NominalDiffTime Source #

Query the chain's average block time, derived from genesis parameters as protocolParamSlotLength / protocolParamActiveSlotsCoefficient.

Throws at least QueryException if query fails.

computeBlockTime :: NominalDiffTime -> Rational -> NominalDiffTime Source #

Compute the block time (expected time between blocks) given a slot length and active slot coefficient.

queryUTxO :: LocalNodeConnectInfo -> QueryPoint -> [Address ShelleyAddr] -> IO UTxO Source #

Query UTxO for all given addresses at given point.

Throws at least QueryException if query fails.

queryUTxOByTxIn :: LocalNodeConnectInfo -> QueryPoint -> [TxIn] -> IO UTxO Source #

Query UTxO for given tx inputs at given point.

Throws at least QueryException if query fails.

queryForCurrentEraInEonExpr :: Eon eon => (AnyCardanoEra -> IO a) -> (forall era. eon era -> LocalStateQueryExpr b p QueryInMode r IO a) -> LocalStateQueryExpr b p QueryInMode r IO a Source #

queryForCurrentEraInShelleyBasedEraExpr :: (forall era. ShelleyBasedEra era -> LocalStateQueryExpr b p QueryInMode r IO a) -> LocalStateQueryExpr b p QueryInMode r IO a Source #

queryForCurrentEraInConwayEraOnwardsExpr :: Eon eon => (forall era. eon era -> LocalStateQueryExpr b p QueryInMode r IO a) -> LocalStateQueryExpr b p QueryInMode r IO a Source #

queryUTxOFor :: LocalNodeConnectInfo -> QueryPoint -> VerificationKey PaymentKey -> IO UTxO Source #

Query UTxO for the address of given verification key at point.

Throws at least QueryException if query fails.

queryStakePools :: LocalNodeConnectInfo -> QueryPoint -> IO (Set PoolId) Source #

Query the current set of registered stake pools.

Throws at least QueryException if query fails.

Helpers

queryCurrentEraExpr :: LocalStateQueryExpr b p QueryInMode r IO AnyCardanoEra Source #

Monadic query expression to get current era.

queryInShelleyBasedEraExpr Source #

Arguments

:: ShelleyBasedEra era

The current running era we can use to query the node

-> QueryInShelleyBasedEra era a 
-> LocalStateQueryExpr b p QueryInMode r IO a 

Monadic query expression for a QueryInShelleyBasedEra.

runQuery :: LocalNodeConnectInfo -> QueryPoint -> QueryInMode a -> IO a Source #

Throws at least QueryException if query fails.

runQueryExpr :: LocalNodeConnectInfo -> QueryPoint -> LocalStateQueryExpr BlockInMode ChainPoint QueryInMode () IO a -> IO a Source #

Throws at least QueryException if query fails.

throwOnEraMismatch :: MonadThrow m => Either EraMismatch a -> m a Source #

throwOnUnsupportedNtcVersion :: MonadThrow m => Either UnsupportedNtcVersionError a -> m a Source #

localNodeConnectInfo :: NetworkId -> SocketPath -> LocalNodeConnectInfo Source #

cardanoModeParams :: ConsensusModeParams Source #