| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cooked.MockChain.State
Description
This module exposes the internal state in which our direct simulation is
run (MockChainState), as well as a restricted and simplified version
(UtxoState). The latter only consists of Utxos with a focus on who owns
those Utxos. You can see this as having some sort of an "account" view of the
ledger state, which typically does not exist in Cardano. This is useful for
two reasons:
- For printing purposes, where it is much more convient to see the available assets as "who owns what" rather than as a set of mixed Utxos.
- For testings purposes, when querying the final state of a run is needed. For instance, properties such as "does Alice indeed owns 3 XXX tokens at the end of this run?" become much easier to express.
Synopsis
- data MockChainState where
- MockChainState :: {..} -> MockChainState
- mcstParamsL :: Lens' MockChainState Params
- mcstLedgerStateL :: Lens' MockChainState EmulatedLedgerState
- mcstOutputsL :: Lens' MockChainState (Map TxOutRef (TxSkelOut, Bool))
- mcstConstitutionL :: Lens' MockChainState (Maybe VScript)
- mcstMOutputL :: TxOutRef -> Lens' MockChainState (Maybe TxSkelOut)
- addOutput :: TxOutRef -> TxSkelOut -> MockChainState -> MockChainState
- removeOutput :: TxOutRef -> MockChainState -> MockChainState
- data UtxoPayloadDatum where
- NoUtxoPayloadDatum :: UtxoPayloadDatum
- SomeUtxoPayloadDatum :: DatumConstrs dat => dat -> Bool -> UtxoPayloadDatum
- utxoPayloadDatumKindAT :: AffineTraversal' UtxoPayloadDatum Bool
- utxoPayloadDatumTypedAT :: (DatumConstrs a, DatumConstrs b) => AffineTraversal UtxoPayloadDatum UtxoPayloadDatum a b
- data UtxoPayload where
- UtxoPayload :: {..} -> UtxoPayload
- utxoPayloadTxOutRefL :: Lens' UtxoPayload TxOutRef
- utxoPayloadValueL :: Lens' UtxoPayload Value
- utxoPayloadDatumL :: Lens' UtxoPayload UtxoPayloadDatum
- utxoPayloadMReferenceScriptHashL :: Lens' UtxoPayload (Maybe ScriptHash)
- utxoPayloadReferenceScriptHashAT :: AffineTraversal' UtxoPayload ScriptHash
- newtype UtxoPayloadSet = UtxoPayloadSet {}
- utxoPayloadSetListI :: Iso' UtxoPayloadSet [UtxoPayload]
- data UtxoState where
- availableUtxosL :: Lens' UtxoState (Map Address UtxoPayloadSet)
- consumedUtxosL :: Lens' UtxoState (Map Address UtxoPayloadSet)
- holdsInState :: ToAddress a => a -> UtxoState -> Value
- mcstToUtxoState :: MockChainState -> UtxoState
MockChainState and associated optics
data MockChainState where Source #
The state used to run the simulation in Direct
Constructors
| MockChainState | |
Fields
| |
Instances
| Show MockChainState Source # | |
Defined in Cooked.MockChain.State Methods showsPrec :: Int -> MockChainState -> ShowS # show :: MockChainState -> String # showList :: [MockChainState] -> ShowS # | |
| RunnableMockChain FullEffs Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem FullEffs a -> [RawMockChainReturn a] Source # | |
| Default MockChainState Source # | |
Defined in Cooked.MockChain.State Methods def :: MockChainState # | |
mcstParamsL :: Lens' MockChainState Params Source #
A lens to set or get the parameters of the MockChainState
mcstLedgerStateL :: Lens' MockChainState EmulatedLedgerState Source #
A lens to set or get the ledger state of the MockChainState
mcstOutputsL :: Lens' MockChainState (Map TxOutRef (TxSkelOut, Bool)) Source #
A lens to set or get the outputs of the MockChainState
mcstConstitutionL :: Lens' MockChainState (Maybe VScript) Source #
A lens to set or get the constitution script of the MockChainState
mcstMOutputL :: TxOutRef -> Lens' MockChainState (Maybe TxSkelOut) Source #
Accesses a given available Utxo from a MockChainState
Helpers to add or remove outputs from a MockChainState
addOutput :: TxOutRef -> TxSkelOut -> MockChainState -> MockChainState Source #
Stores an output in a MockChainState
removeOutput :: TxOutRef -> MockChainState -> MockChainState Source #
Removes an output from the MockChainState. This does not actually remove
it from the map, but instead marks its availability to False
UtxoState: A simplified, address-focused view on a MockChainState
data UtxoPayloadDatum where Source #
A simplified version of a TxSkelOutDatum which only
stores the actual datum and whether it is hashed (True) or inline
(False). The only difference is that whether the datum was resolved in the
transaction creating it on the ledger is absent, which makes sense after the
fact.
Constructors
| NoUtxoPayloadDatum :: UtxoPayloadDatum | |
| SomeUtxoPayloadDatum :: DatumConstrs dat => dat -> Bool -> UtxoPayloadDatum |
Instances
| Show UtxoPayloadDatum Source # | |
Defined in Cooked.MockChain.State Methods showsPrec :: Int -> UtxoPayloadDatum -> ShowS # show :: UtxoPayloadDatum -> String # showList :: [UtxoPayloadDatum] -> ShowS # | |
| Eq UtxoPayloadDatum Source # | |
Defined in Cooked.MockChain.State Methods (==) :: UtxoPayloadDatum -> UtxoPayloadDatum -> Bool # (/=) :: UtxoPayloadDatum -> UtxoPayloadDatum -> Bool # | |
| Ord UtxoPayloadDatum Source # | |
Defined in Cooked.MockChain.State Methods compare :: UtxoPayloadDatum -> UtxoPayloadDatum -> Ordering # (<) :: UtxoPayloadDatum -> UtxoPayloadDatum -> Bool # (<=) :: UtxoPayloadDatum -> UtxoPayloadDatum -> Bool # (>) :: UtxoPayloadDatum -> UtxoPayloadDatum -> Bool # (>=) :: UtxoPayloadDatum -> UtxoPayloadDatum -> Bool # max :: UtxoPayloadDatum -> UtxoPayloadDatum -> UtxoPayloadDatum # min :: UtxoPayloadDatum -> UtxoPayloadDatum -> UtxoPayloadDatum # | |
utxoPayloadDatumKindAT :: AffineTraversal' UtxoPayloadDatum Bool Source #
Focuses on whether on not this UtxoPayloadDatum isHashed
utxoPayloadDatumTypedAT :: (DatumConstrs a, DatumConstrs b) => AffineTraversal UtxoPayloadDatum UtxoPayloadDatum a b Source #
Extracts, or sets, the typed datum of a UtxoPayloadDatum following the
same rules as txSkelOutDatumTypedAT
data UtxoPayload where Source #
A convenient wrapping of the interesting information of a UTxO.
Constructors
| UtxoPayload | |
Fields
| |
Instances
| Show UtxoPayload Source # | |
Defined in Cooked.MockChain.State Methods showsPrec :: Int -> UtxoPayload -> ShowS # show :: UtxoPayload -> String # showList :: [UtxoPayload] -> ShowS # | |
| Eq UtxoPayload Source # | |
Defined in Cooked.MockChain.State | |
utxoPayloadTxOutRefL :: Lens' UtxoPayload TxOutRef Source #
A lens to set or get the UTxO reference from this UtxoPayload
utxoPayloadValueL :: Lens' UtxoPayload Value Source #
A lens to set or get the value from this UtxoPayload
utxoPayloadDatumL :: Lens' UtxoPayload UtxoPayloadDatum Source #
A lens to set or get the datum from this UtxoPayload
utxoPayloadMReferenceScriptHashL :: Lens' UtxoPayload (Maybe ScriptHash) Source #
A lens to set or get the optional reference script hash from this
UtxoPayload
utxoPayloadReferenceScriptHashAT :: AffineTraversal' UtxoPayload ScriptHash Source #
Focusing on the optional reference script hash of a UtxoPayload
newtype UtxoPayloadSet Source #
Represents a set of payloads.
Constructors
| UtxoPayloadSet | |
Fields
| |
Instances
utxoPayloadSetListI :: Iso' UtxoPayloadSet [UtxoPayload] Source #
Going back and forth between a list of UtxoPayload and a UtxoPayloadSet
A description of who owns what in a blockchain. Owners are addresses and
they each own a UtxoPayloadSet.
Constructors
| UtxoState | |
Fields
| |
availableUtxosL :: Lens' UtxoState (Map Address UtxoPayloadSet) Source #
A lens to set or get the available UTxOs from a UtxoState
consumedUtxosL :: Lens' UtxoState (Map Address UtxoPayloadSet) Source #
A lens to set or get the consumed UTxOs from a UtxoState
Querying the assets owned by a given address
holdsInState :: ToAddress a => a -> UtxoState -> Value Source #
Total value accessible to what's pointed by the address.
Transforming a MockChainState into an UtxoState
mcstToUtxoState :: MockChainState -> UtxoState Source #
Builds a UtxoState from a MockChainState