Safe Haskell | None |
---|---|
Language | Haskell2010 |
If you want to run the node emulator without using the Contract
monad, this module provides a simple MTL-based interface.
Synopsis
- queueTx :: MonadEmulator m => CardanoTx -> m ()
- nextSlot :: MonadEmulator m => m ()
- currentSlot :: MonadEmulator m => m Slot
- awaitSlot :: MonadEmulator m => Slot -> m ()
- utxosAt :: MonadEmulator m => CardanoAddress -> m UtxoIndex
- utxosAtPlutus :: MonadEmulator m => CardanoAddress -> m (Map TxOutRef DecoratedTxOut)
- utxoAtTxOutRef :: MonadEmulator m => TxIn -> m (Maybe TxOut)
- utxoAtTxOutRefPlutus :: MonadEmulator m => TxOutRef -> m (Maybe DecoratedTxOut)
- fundsAt :: MonadEmulator m => CardanoAddress -> m Value
- lookupDatum :: MonadEmulator m => DatumHash -> m (Maybe Datum)
- balanceTx :: MonadEmulator m => UtxoIndex -> CardanoAddress -> CardanoBuildTx -> m CardanoTx
- signTx :: (MonadEmulator m, Foldable f) => f PaymentPrivateKey -> CardanoTx -> m CardanoTx
- submitUnbalancedTx :: (MonadEmulator m, Foldable f) => UtxoIndex -> CardanoAddress -> f PaymentPrivateKey -> CardanoBuildTx -> m CardanoTx
- submitTxConfirmed :: (MonadEmulator m, Foldable f) => UtxoIndex -> CardanoAddress -> f PaymentPrivateKey -> CardanoBuildTx -> m CardanoTx
- payToAddress :: MonadEmulator m => (CardanoAddress, PaymentPrivateKey) -> CardanoAddress -> Value -> m TxId
- logDebug :: (ToJSON a, MonadEmulator m) => a -> m ()
- logInfo :: (ToJSON a, MonadEmulator m) => a -> m ()
- logWarn :: (ToJSON a, MonadEmulator m) => a -> m ()
- logError :: (ToJSON a, MonadEmulator m) => a -> m ()
- data EmulatorState = EmulatorState !ChainState !AddressMap !(Map DatumHash Datum)
- esChainState :: Lens' EmulatorState ChainState
- esAddressMap :: Lens' EmulatorState AddressMap
- esDatumMap :: Lens' EmulatorState (Map DatumHash Datum)
- data EmulatorError
- = BalancingError !BalancingError
- | ValidationError !ValidationErrorInPhase
- | ToCardanoError !ToCardanoError
- type EmulatorLogs = Seq (LogMessage EmulatorMsg)
- data EmulatorMsg
- = GenericMsg Value
- | TxBalanceMsg TxBalanceMsg
- | ChainEvent ChainEvent
- data LogMessage a = LogMessage {
- _logLevel :: LogLevel
- _logMessageContent :: a
- type MonadEmulator m = (MonadRWS Params EmulatorLogs EmulatorState m, MonadError EmulatorError m)
- type EmulatorT m = ExceptT EmulatorError (RWST Params EmulatorLogs EmulatorState m)
- type EmulatorM = EmulatorT Identity
- emptyEmulatorState :: EmulatorState
- emptyEmulatorStateWithInitialDist :: Map CardanoAddress Value -> EmulatorState
- getParams :: MonadEmulator m => m Params
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
:: MonadEmulator m | |
=> UtxoIndex | Just the transaction inputs, not the entire |
-> 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.
:: (MonadEmulator m, Foldable f) | |
=> f PaymentPrivateKey | Signatures |
-> CardanoTx | |
-> m CardanoTx |
Sign a transaction with the given signatures.
:: (MonadEmulator m, Foldable f) | |
=> UtxoIndex | Just the transaction inputs, not the entire |
-> CardanoAddress | Wallet address |
-> f PaymentPrivateKey | Signatures |
-> CardanoBuildTx | |
-> m CardanoTx |
Balance a transaction, sign it with the given signatures, and finally queue it.
:: (MonadEmulator m, Foldable f) | |
=> UtxoIndex | Just the transaction inputs, not the entire |
-> 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 #
EmulatorState !ChainState !AddressMap !(Map DatumHash Datum) |
Instances
Show EmulatorState Source # | |
Defined in Cardano.Node.Emulator.Internal.API | |
IsRunnable EmulatorM Source # | |
Defined in Cardano.Node.Emulator.Test | |
HasChainIndex EmulatorM Source # | |
type Realized EmulatorM a | |
Defined in Cardano.Node.Emulator.Test type Realized EmulatorM a = a |
esChainState :: Lens' EmulatorState ChainState Source #
esAddressMap :: Lens' EmulatorState AddressMap Source #
esDatumMap :: Lens' EmulatorState (Map DatumHash Datum) Source #
data EmulatorError Source #
BalancingError !BalancingError | |
ValidationError !ValidationErrorInPhase | |
ToCardanoError !ToCardanoError |
Instances
Show EmulatorError Source # | |
Defined in Cardano.Node.Emulator.Internal.API | |
Exception EmulatorError Source # | |
Defined in Cardano.Node.Emulator.Internal.API | |
IsRunnable EmulatorM Source # | |
Defined in Cardano.Node.Emulator.Test | |
HasChainIndex EmulatorM Source # | |
type Realized EmulatorM a | |
Defined in Cardano.Node.Emulator.Test type Realized EmulatorM a = a |
type EmulatorLogs = Seq (LogMessage EmulatorMsg) Source #
data EmulatorMsg Source #
Instances
data LogMessage a #
LogMessage | |
|
Instances
type MonadEmulator m = (MonadRWS Params EmulatorLogs EmulatorState m, MonadError EmulatorError m) Source #
type EmulatorT m = ExceptT EmulatorError (RWST Params EmulatorLogs EmulatorState m) Source #
emptyEmulatorStateWithInitialDist :: Map CardanoAddress Value -> EmulatorState Source #
getParams :: MonadEmulator m => m Params Source #