cooked-validators
Safe HaskellSafe-Inferred
LanguageHaskell2010

Cooked.MockChain.Runnable

Description

This module exposes the infrastructure to execute mockchain runs. In particular:

  • The notion of initial distribution (a list of payments)
  • The return types of the runs (raw and refined)
  • The initial configuration with which to execute a run
  • The notion of RunnableMockChain to actually execute computations
Synopsis

Initial distribution of funds

type InitialDistribution = [TxSkelOut] Source #

Describes the initial distribution of UTxOs per user.

The following specifies a starting state where wallet 1 owns two UTxOs, one with 42 Ada and one with 2 Ada and one TOK token; wallet 2 owns a single UTxO with 10 Ada and wallet 3 has 10 Ada and a permanent value

i0 = distributionFromList $
       [ (wallet 1 , [ ada 42 , ada 2 <> quickValue "TOK" 1 ]
       , (wallet 2 , [ ada 10 ])
       , (wallet 3 , [ ada 10 <> permanentValue "XYZ" 10])
       ]

Note that payment issued through an initial distribution will be attached enough ADA to sustain themselves unless a fixed value is explicitly required.

initialDistributionTemplate :: InitialDistribution Source #

4 UTxOs with 100 Ada each, for each of the first 4 knownWallets

distributionFromList :: IsTxSkelOutAllowedOwner owner => [(owner, [Value])] -> InitialDistribution Source #

Creating a initial distribution with simple values assigned to owners

type RawMockChainReturn a = (MockChainJournal, (MockChainState, Either MockChainError a)) Source #

Raw return type of running a mockchain

data MockChainReturn a where Source #

The returned type when running a mockchain. This is both a reorganizing and filtering of the natural returned type RawMockChainReturn.

Constructors

MockChainReturn 

Fields

type FunOnMockChainResult a b = RawMockChainReturn a -> b Source #

The type of functions transforming an element of type RawMockChainReturn a into an element of type b

data MockChainConf a b where Source #

Configuration from which to run a mockchain

Constructors

MockChainConf 

Fields

mockChainConfTemplate :: MockChainConf a (MockChainReturn a) Source #

The default MockChainConf, which uses the default initial state and initial distribution, and returns a refined MockChainReturn

class RunnableMockChain effs where Source #

The class of effects that represent a mockchain run

Methods

runMockChain :: MockChainState -> Sem effs a -> [RawMockChainReturn a] Source #

Runs a computation from an initial MockChainState, while returning a list of RawMockChainReturn

runMockChainDef :: (RunnableMockChain effs, Member MockChainWrite effs) => Sem effs a -> [MockChainReturn a] Source #

Runs a RunnableMockChain from a default configuration