cardano-node-emulator-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Cardano.Node.Emulator.API

Description

If you want to run the node emulator without using the Contract monad, this module provides a simple MTL-based interface.

Synopsis

Updating the blockchain

queueTx :: MonadEmulator m => CardanoTx -> m () Source #

Queue the transaction, it will be processed when nextSlot is called.

nextSlot :: MonadEmulator m => m () Source #

Process the queued transactions and increase the slot number.

currentSlot :: MonadEmulator m => m Slot Source #

Get the current slot number of the emulated node.

awaitSlot :: MonadEmulator m => Slot -> m () Source #

Call nextSlot until the current slot number equals or exceeds the given slot number.

Querying the blockchain

utxosAt :: MonadEmulator m => CardanoAddress -> m UtxoIndex Source #

Query the unspent transaction outputs at the given address.

utxosAtPlutus :: MonadEmulator m => CardanoAddress -> m (Map TxOutRef DecoratedTxOut) Source #

Query the unspent transaction outputs at the given address (using Plutus types).

utxoAtTxOutRef :: MonadEmulator m => TxIn -> m (Maybe TxOut) Source #

Resolve the transaction output reference.

utxoAtTxOutRefPlutus :: MonadEmulator m => TxOutRef -> m (Maybe DecoratedTxOut) Source #

Resolve the transaction output reference (using Plutus types).

fundsAt :: MonadEmulator m => CardanoAddress -> m Value Source #

Query the total value of the unspent transaction outputs at the given address.

lookupDatum :: MonadEmulator m => DatumHash -> m (Maybe Datum) Source #

Resolve a datum hash to an actual datum, if known.

Transactions

balanceTx Source #

Arguments

:: MonadEmulator m 
=> UtxoIndex

Just the transaction inputs, not the entire UTxO.

-> CardanoAddress

Wallet address

-> CardanoBuildTx 
-> m CardanoTx 

Balance an unbalanced transaction, using funds from the given wallet if needed, and returning any remaining value to the same wallet.

signTx Source #

Arguments

:: (MonadEmulator m, Foldable f) 
=> f PaymentPrivateKey

Signatures

-> CardanoTx 
-> m CardanoTx 

Sign a transaction with the given signatures.

submitUnbalancedTx Source #

Arguments

:: (MonadEmulator m, Foldable f) 
=> UtxoIndex

Just the transaction inputs, not the entire UTxO.

-> CardanoAddress

Wallet address

-> f PaymentPrivateKey

Signatures

-> CardanoBuildTx 
-> m CardanoTx 

Balance a transaction, sign it with the given signatures, and finally queue it.

submitTxConfirmed Source #

Arguments

:: (MonadEmulator m, Foldable f) 
=> UtxoIndex

Just the transaction inputs, not the entire UTxO.

-> CardanoAddress 
-> f PaymentPrivateKey 
-> CardanoBuildTx 
-> m CardanoTx 

payToAddress :: MonadEmulator m => (CardanoAddress, PaymentPrivateKey) -> CardanoAddress -> Value -> m TxId Source #

Create a transaction that transfers funds from one address to another, and sign and submit it.

Logging

logDebug :: (ToJSON a, MonadEmulator m) => a -> m () Source #

Log a message at the Debug level

logInfo :: (ToJSON a, MonadEmulator m) => a -> m () Source #

Log a message at the Info level

logWarn :: (ToJSON a, MonadEmulator m) => a -> m () Source #

Log a message at the Warning level

logError :: (ToJSON a, MonadEmulator m) => a -> m () Source #

Log a message at the Error level

Types

data EmulatorState Source #

Constructors

EmulatorState !ChainState !AddressMap !(Map DatumHash Datum) 

Instances

Instances details
Show EmulatorState Source # 
Instance details

Defined in Cardano.Node.Emulator.Internal.API

IsRunnable EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

Methods

awaitSlot :: SlotNo -> EmulatorM ()

HasChainIndex EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

type Realized EmulatorM a 
Instance details

Defined in Cardano.Node.Emulator.Test

type Realized EmulatorM a = a

esAddressMap :: Lens' EmulatorState AddressMap Source #

esDatumMap :: Lens' EmulatorState (Map DatumHash Datum) Source #

data EmulatorMsg Source #

Instances

Instances details
Eq EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

Show EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

Generic EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

Associated Types

type Rep EmulatorMsg :: Type -> Type Source #

FromJSON EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

Methods

parseJSON :: Value -> Parser EmulatorMsg

parseJSONList :: Value -> Parser [EmulatorMsg]

ToJSON EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

Methods

toJSON :: EmulatorMsg -> Value

toEncoding :: EmulatorMsg -> Encoding

toJSONList :: [EmulatorMsg] -> Value

toEncodingList :: [EmulatorMsg] -> Encoding

Pretty EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

Methods

pretty :: EmulatorMsg -> Doc ann

prettyList :: [EmulatorMsg] -> Doc ann

IsRunnable EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

Methods

awaitSlot :: SlotNo -> EmulatorM ()

HasChainIndex EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

type Rep EmulatorMsg Source # 
Instance details

Defined in Cardano.Node.Emulator.LogMessages

type Rep EmulatorMsg = D1 ('MetaData "EmulatorMsg" "Cardano.Node.Emulator.LogMessages" "cardano-node-emulator-1.2.0.0-1RjxyDmnwHSAn2KgGdAUXD" 'False) (C1 ('MetaCons "GenericMsg" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: (C1 ('MetaCons "TxBalanceMsg" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxBalanceMsg)) :+: C1 ('MetaCons "ChainEvent" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ChainEvent))))
type Realized EmulatorM a 
Instance details

Defined in Cardano.Node.Emulator.Test

type Realized EmulatorM a = a

data LogMessage a #

Constructors

LogMessage 

Fields

Instances

Instances details
Functor LogMessage 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Methods

fmap :: (a -> b) -> LogMessage a -> LogMessage b Source #

(<$) :: a -> LogMessage b -> LogMessage a Source #

Foldable LogMessage 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Methods

fold :: Monoid m => LogMessage m -> m Source #

foldMap :: Monoid m => (a -> m) -> LogMessage a -> m Source #

foldMap' :: Monoid m => (a -> m) -> LogMessage a -> m Source #

foldr :: (a -> b -> b) -> b -> LogMessage a -> b Source #

foldr' :: (a -> b -> b) -> b -> LogMessage a -> b Source #

foldl :: (b -> a -> b) -> b -> LogMessage a -> b Source #

foldl' :: (b -> a -> b) -> b -> LogMessage a -> b Source #

foldr1 :: (a -> a -> a) -> LogMessage a -> a Source #

foldl1 :: (a -> a -> a) -> LogMessage a -> a Source #

toList :: LogMessage a -> [a] Source #

null :: LogMessage a -> Bool Source #

length :: LogMessage a -> Int Source #

elem :: Eq a => a -> LogMessage a -> Bool Source #

maximum :: Ord a => LogMessage a -> a Source #

minimum :: Ord a => LogMessage a -> a Source #

sum :: Num a => LogMessage a -> a Source #

product :: Num a => LogMessage a -> a Source #

Traversable LogMessage 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Methods

traverse :: Applicative f => (a -> f b) -> LogMessage a -> f (LogMessage b) Source #

sequenceA :: Applicative f => LogMessage (f a) -> f (LogMessage a) Source #

mapM :: Monad m => (a -> m b) -> LogMessage a -> m (LogMessage b) Source #

sequence :: Monad m => LogMessage (m a) -> m (LogMessage a) Source #

IsRunnable EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

Methods

awaitSlot :: SlotNo -> EmulatorM ()

HasChainIndex EmulatorM Source # 
Instance details

Defined in Cardano.Node.Emulator.Test

Eq a => Eq (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Ord a => Ord (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Show a => Show (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Generic (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Associated Types

type Rep (LogMessage a) :: Type -> Type Source #

Methods

from :: LogMessage a -> Rep (LogMessage a) x Source #

to :: Rep (LogMessage a) x -> LogMessage a Source #

FromJSON a => FromJSON (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Methods

parseJSON :: Value -> Parser (LogMessage a)

parseJSONList :: Value -> Parser [LogMessage a]

ToJSON a => ToJSON (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Methods

toJSON :: LogMessage a -> Value

toEncoding :: LogMessage a -> Encoding

toJSONList :: [LogMessage a] -> Value

toEncodingList :: [LogMessage a] -> Encoding

Pretty a => Pretty (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

Methods

pretty :: LogMessage a -> Doc ann

prettyList :: [LogMessage a] -> Doc ann

type Realized EmulatorM a 
Instance details

Defined in Cardano.Node.Emulator.Test

type Realized EmulatorM a = a
type Rep (LogMessage a) 
Instance details

Defined in Control.Monad.Freer.Extras.Log

type Rep (LogMessage a) = D1 ('MetaData "LogMessage" "Control.Monad.Freer.Extras.Log" "freer-extras-1.2.0.0-1q4AUo79Td5ISTeTXorMWT" 'False) (C1 ('MetaCons "LogMessage" 'PrefixI 'True) (S1 ('MetaSel ('Just "_logLevel") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 LogLevel) :*: S1 ('MetaSel ('Just "_logMessageContent") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedStrict) (Rec0 a)))