Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Cooked.MockChain.MockChainSt
Description
This module exposes the internal state in which our direct simulation is run, and functions to update and querry it.
Synopsis
- data MockChainSt = MockChainSt {}
- getIndex :: UtxoIndex -> Map TxOutRef TxOut
- mcstToUtxoState :: MockChainSt -> UtxoState
- mcstToEmulatedLedgerState :: MockChainSt -> EmulatedLedgerState
- addDatums :: [(DatumHash, TxSkelOutDatum)] -> MockChainSt -> MockChainSt
- removeDatums :: [DatumHash] -> MockChainSt -> MockChainSt
- addScript :: (ToScriptHash s, ToVersioned Script s) => s -> MockChainSt -> MockChainSt
- mockChainSt0From :: MonadBlockChainBalancing m => InitialDistribution -> m MockChainSt
- referenceScriptMap0From :: InitialDistribution -> Map ScriptHash (Versioned Script)
- scriptMap0From :: InitialDistribution -> Map ScriptHash (Versioned Script)
- datumMap0From :: InitialDistribution -> Map DatumHash (TxSkelOutDatum, Integer)
- utxoIndex0From :: MonadBlockChainBalancing m => InitialDistribution -> m UtxoIndex
- utxoIndex0 :: MonadBlockChainBalancing m => m UtxoIndex
Documentation
data MockChainSt Source #
The state used to run the simulation in Direct
Constructors
MockChainSt | |
Fields
|
Instances
Show MockChainSt Source # | |
Defined in Cooked.MockChain.MockChainSt Methods showsPrec :: Int -> MockChainSt -> ShowS # show :: MockChainSt -> String # showList :: [MockChainSt] -> ShowS # | |
Default MockChainSt Source # | |
Defined in Cooked.MockChain.MockChainSt Methods def :: MockChainSt # | |
Eq MockChainSt Source # | |
Defined in Cooked.MockChain.MockChainSt | |
Monad m => MonadState MockChainSt (MockChainT m) Source # | |
Defined in Cooked.MockChain.Direct Methods get :: MockChainT m MockChainSt # put :: MockChainSt -> MockChainT m () # state :: (MockChainSt -> (a, MockChainSt)) -> MockChainT m a # |
getIndex :: UtxoIndex -> Map TxOutRef TxOut Source #
Converts a builtin UtxoIndex into our own usable map between utxos and associated outputs.
mcstToUtxoState :: MockChainSt -> UtxoState Source #
Builds a UtxoState
from a MockChainSt
mcstToEmulatedLedgerState :: MockChainSt -> EmulatedLedgerState Source #
Generating an emulated state for the emulator from a mockchain state and some parameters, based on a standard initial state
addDatums :: [(DatumHash, TxSkelOutDatum)] -> MockChainSt -> MockChainSt Source #
Adds a list of pairs (datumHash, datum)
into a MockChainSt
removeDatums :: [DatumHash] -> MockChainSt -> MockChainSt Source #
Removes a certain amound of datum hashes from a MockChainSt
addScript :: (ToScriptHash s, ToVersioned Script s) => s -> MockChainSt -> MockChainSt Source #
Stores a script in a MockChainSt
Initial MockChainSt
from an InitialDistribution
mockChainSt0From :: MonadBlockChainBalancing m => InitialDistribution -> m MockChainSt Source #
Builds a MockChainSt
from an InitialDistribution
. This lives in
MonadBlockChainBalancing
because the creation of mcstIndex
is impure
referenceScriptMap0From :: InitialDistribution -> Map ScriptHash (Versioned Script) Source #
Collects the reference scripts present in an InitialDistribution
scriptMap0From :: InitialDistribution -> Map ScriptHash (Versioned Script) Source #
Collects the scripts paid to in an InitialDistribution
datumMap0From :: InitialDistribution -> Map DatumHash (TxSkelOutDatum, Integer) Source #
Collects the datums paid in an InitialDistribution
utxoIndex0From :: MonadBlockChainBalancing m => InitialDistribution -> m UtxoIndex Source #
This creates the initial UtxoIndex from an initial distribution by submitting an initial transaction with the appropriate content:
- inputs consist of a single dummy pseudo input
- outputs are translated from the
TxSkelOut
list in the initial distribution
Two things to note:
- We don't know what Magic means for the network ID (TODO)
- The genesis key hash has been taken from https://github.com/input-output-hk/cardano-node/blob/543b267d75d3d448e1940f9ec04b42bd01bbb16b/cardano-api/test/Test/Cardano/Api/Genesis.hs#L60
utxoIndex0 :: MonadBlockChainBalancing m => m UtxoIndex Source #
Same as utxoIndex0From
with the default InitialDistribution