| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Cooked.MockChain.Read
Description
This module exposes primitives to query the current state of the blockchain.
Synopsis
- data MockChainRead :: Effect
- runMockChainRead :: forall effs a. Members '[State MockChainState, Error ToCardanoError, Error MockChainError] effs => Sem (MockChainRead : effs) a -> Sem effs a
- getParams :: Member MockChainRead effs => Sem effs Params
- govActionDeposit :: Member MockChainRead effs => Sem effs Lovelace
- dRepDeposit :: Member MockChainRead effs => Sem effs Lovelace
- stakeAddressDeposit :: Member MockChainRead effs => Sem effs Lovelace
- stakePoolDeposit :: Member MockChainRead effs => Sem effs Lovelace
- txSkelDepositedValueInCertificates :: Member MockChainRead effs => TxSkel -> Sem effs Lovelace
- txSkelDepositedValueInProposals :: Member MockChainRead effs => TxSkel -> Sem effs Lovelace
- txSkelAllScripts :: Member MockChainRead effs => TxSkel -> Sem effs [VScript]
- txSkelInputScripts :: Member MockChainRead effs => TxSkel -> Sem effs [VScript]
- txSkelInputValue :: Member MockChainRead effs => TxSkel -> Sem effs Value
- currentSlot :: Member MockChainRead effs => Sem effs Slot
- currentMSRange :: Members '[MockChainRead, Fail] effs => Sem effs (POSIXTime, POSIXTime)
- getEnclosingSlot :: Member MockChainRead effs => POSIXTime -> Sem effs Slot
- slotRangeBefore :: Members '[MockChainRead, Fail] effs => POSIXTime -> Sem effs SlotRange
- slotRangeAfter :: Members '[MockChainRead, Fail] effs => POSIXTime -> Sem effs SlotRange
- slotToMSRange :: (Members '[MockChainRead, Fail] effs, Integral i) => i -> Sem effs (POSIXTime, POSIXTime)
- allUtxos :: Member MockChainRead effs => Sem effs Utxos
- utxosAt :: (Member MockChainRead effs, ToCredential cred) => cred -> Sem effs Utxos
- txSkelOutByRef :: Member MockChainRead effs => TxOutRef -> Sem effs TxSkelOut
- utxosFromCardanoTx :: Member MockChainRead effs => CardanoTx -> Sem effs [(TxOutRef, TxSkelOut)]
- lookupUtxos :: Member MockChainRead effs => [TxOutRef] -> Sem effs (Map TxOutRef TxSkelOut)
- previewByRef :: (Member MockChainRead effs, Is af An_AffineFold) => Optic' af is TxSkelOut c -> TxOutRef -> Sem effs (Maybe c)
- viewByRef :: (Member MockChainRead effs, Is g A_Getter) => Optic' g is TxSkelOut c -> TxOutRef -> Sem effs c
- getConstitutionScript :: Member MockChainRead effs => Sem effs (Maybe VScript)
- getCurrentReward :: (Member MockChainRead effs, ToCredential c) => c -> Sem effs (Maybe Lovelace)
The MockChainRead effect
data MockChainRead :: Effect Source #
An effect that offers primitives to query the current state of the mockchain. As its name suggests, this effect is read-only and does not alter the state in any way.
Instances
| RunnableMockChain DirectEffs Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem DirectEffs a -> [RawMockChainReturn a] Source # | |
| RunnableMockChain FullEffs Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem FullEffs a -> [RawMockChainReturn a] Source # | |
| InterpretAlone extraEff => RunnableMockChain (ExtendedStagedEffs extraEff) Source # | |
Defined in Cooked.MockChain.Instances Methods runMockChain :: MockChainState -> Sem (ExtendedStagedEffs extraEff) a -> [RawMockChainReturn a] Source # | |
runMockChainRead :: forall effs a. Members '[State MockChainState, Error ToCardanoError, Error MockChainError] effs => Sem (MockChainRead : effs) a -> Sem effs a Source #
The interpretation for read-only effect in the blockchain state
Queries related to protocol parameters
getParams :: Member MockChainRead effs => Sem effs Params Source #
Returns the emulator parameters, including protocol parameters
govActionDeposit :: Member MockChainRead effs => Sem effs Lovelace Source #
Retrieves the required governance action deposit amount
dRepDeposit :: Member MockChainRead effs => Sem effs Lovelace Source #
Retrieves the required drep deposit amount
stakeAddressDeposit :: Member MockChainRead effs => Sem effs Lovelace Source #
Retrieves the required stake address deposit amount
stakePoolDeposit :: Member MockChainRead effs => Sem effs Lovelace Source #
Retrieves the required stake pool deposit amount
Queries related to TxSkel
txSkelDepositedValueInCertificates :: Member MockChainRead effs => TxSkel -> Sem effs Lovelace Source #
Retrieves the total amount of lovelace deposited in certificates in this skeleton. Note that unregistering a staking address or a dRep lead to a negative deposit (a withdrawal, in fact) which means this function can return a negative amount of lovelace, which is intended. The deposited amounts are dictated by the current protocol parameters, and computed as such.
txSkelDepositedValueInProposals :: Member MockChainRead effs => TxSkel -> Sem effs Lovelace Source #
Retrieves the total amount of lovelace deposited in proposals in this
skeleton (equal to govActionDeposit times the number of proposals)
txSkelAllScripts :: Member MockChainRead effs => TxSkel -> Sem effs [VScript] Source #
Returns all scripts involved in this TxSkel
txSkelInputScripts :: Member MockChainRead effs => TxSkel -> Sem effs [VScript] Source #
Returns all scripts which guard transaction inputs
txSkelInputValue :: Member MockChainRead effs => TxSkel -> Sem effs Value Source #
look up the UTxOs the transaction consumes, and sum their values.
Queries related to timing
currentSlot :: Member MockChainRead effs => Sem effs Slot Source #
Returns the current slot
currentMSRange :: Members '[MockChainRead, Fail] effs => Sem effs (POSIXTime, POSIXTime) Source #
Returns the closed ms interval corresponding to the current slot
getEnclosingSlot :: Member MockChainRead effs => POSIXTime -> Sem effs Slot Source #
Return the slot that contains the given time. See slotToMSRange for
some satisfied equational properties.
slotRangeBefore :: Members '[MockChainRead, Fail] effs => POSIXTime -> Sem effs SlotRange Source #
The infinite range of slots ending before or at the given time
slotRangeAfter :: Members '[MockChainRead, Fail] effs => POSIXTime -> Sem effs SlotRange Source #
The infinite range of slots starting after or at the given time
slotToMSRange :: (Members '[MockChainRead, Fail] effs, Integral i) => i -> Sem effs (POSIXTime, POSIXTime) Source #
Returns the closed ms interval corresponding to the slot with the given number. It holds that
slotToMSRange (getEnclosingSlot t) == (a, b) ==> a <= t <= b
and
slotToMSRange n == (a, b) ==> getEnclosingSlot a == n && getEnclosingSlot b == n
and
slotToMSRange n == (a, b) ==> getEnclosingSlot (a-1) == n-1 && getEnclosingSlot (b+1) == n+1
Queries related to fetching UTxOs
allUtxos :: Member MockChainRead effs => Sem effs Utxos Source #
Returns a list of all currently known outputs
utxosAt :: (Member MockChainRead effs, ToCredential cred) => cred -> Sem effs Utxos Source #
Returns a list of all UTxOs at a certain address.
txSkelOutByRef :: Member MockChainRead effs => TxOutRef -> Sem effs TxSkelOut Source #
Returns an output given a reference to it
utxosFromCardanoTx :: Member MockChainRead effs => CardanoTx -> Sem effs [(TxOutRef, TxSkelOut)] Source #
lookupUtxos :: Member MockChainRead effs => [TxOutRef] -> Sem effs (Map TxOutRef TxSkelOut) Source #
Go through all of the TxOutRefs in the list and look them up in the
state of the blockchain, throwing an error if one of them cannot be resolved.
previewByRef :: (Member MockChainRead effs, Is af An_AffineFold) => Optic' af is TxSkelOut c -> TxOutRef -> Sem effs (Maybe c) Source #
Retrieves an output and previews a specific element out of it
viewByRef :: (Member MockChainRead effs, Is g A_Getter) => Optic' g is TxSkelOut c -> TxOutRef -> Sem effs c Source #
Retrieves an output and views a specific element out of it
Other queries
getConstitutionScript :: Member MockChainRead effs => Sem effs (Maybe VScript) Source #
Gets the current official constitution script
getCurrentReward :: (Member MockChainRead effs, ToCredential c) => c -> Sem effs (Maybe Lovelace) Source #
Gets the current reward associated with a credential