plutus-contract-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Trace.Emulator

Synopsis

Documentation

data ContractHandle w s e Source #

A reference to a running contract in the emulator.

data ContractInstanceTag Source #

A user-defined tag for a contract instance. Used to find the instance's log messages in the emulator log.

Instances

Instances details
Eq ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Ord ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Show ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

IsString ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Generic ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Associated Types

type Rep ContractInstanceTag :: Type -> Type Source #

NFData ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

ToJSON ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

FromJSON ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Pretty ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

type Rep ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

type Rep ContractInstanceTag = D1 ('MetaData "ContractInstanceTag" "Plutus.Trace.Emulator.Types" "plutus-contract-0.1.0.0-2DbvKQdtEvHK4UkDq1ndDW" 'False) (C1 ('MetaCons "ContractInstanceTag" 'PrefixI 'True) (S1 ('MetaSel ('Just "unContractInstanceTag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text) :*: S1 ('MetaSel ('Just "shortContractInstanceTag") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Text)))

Constructing Traces

assert :: forall effs. Member Assert effs => String -> (EmulatorState -> Bool) -> Eff effs () Source #

activateContract :: forall (contract :: Type -> Row Type -> Type -> Type -> Type) (s :: Row Type) e w a. (IsContract contract, ContractConstraints s, Show e, FromJSON e, ToJSON e, ToJSON w, Monoid w, FromJSON w) => forall effs. Member StartContract effs => Wallet -> contract w s e a -> ContractInstanceTag -> Eff effs (ContractHandle w s e) Source #

activateContractWallet :: forall contract w s e effs. (IsContract contract, ContractConstraints s, Show e, ToJSON e, FromJSON e, ToJSON w, FromJSON w, Member StartContract effs, Monoid w) => Wallet -> contract w s e () -> Eff effs (ContractHandle w s e) Source #

Like activateContract, but using walletInstanceTag for the tag.

walletInstanceTag :: Wallet -> ContractInstanceTag Source #

The ContractInstanceTag for the contract instance of a wallet. See note [Wallet contract instances]

callEndpoint :: forall l ep w s e effs. (ToJSON ep, ContractConstraints s, HasEndpoint l ep s, Member RunContract effs) => ContractHandle w s e -> ep -> Eff effs () Source #

Call an endpoint on a contract instance.

getContractState :: forall w (s :: Row Type) e. (ContractConstraints s, FromJSON e, FromJSON w, ToJSON w) => forall effs. Member RunContract effs => ContractHandle w s e -> Eff effs (ContractInstanceState w s e ()) Source #

observableState :: forall w s e effs. (Member RunContract effs, ContractConstraints s, FromJSON e, FromJSON w, ToJSON w) => ContractHandle w s e -> Eff effs w Source #

Get the observable state w of a contract instance.

activeEndpoints :: forall w s e effs. (Member RunContract effs, ContractConstraints s, FromJSON e, FromJSON w, ToJSON w) => ContractHandle w s e -> Eff effs [ActiveEndpoint] Source #

Get the active endpoints of a contract instance.

liftWallet :: forall a. forall effs. Member EmulatedWalletAPI effs => Wallet -> Eff ('(:) WalletEffect ('(:) (Error WalletAPIError) ('(:) (LogMsg Text) ('[] :: [Type -> Type])))) a -> Eff effs a Source #

payToWallet :: forall effs. Member EmulatedWalletAPI effs => Wallet -> Wallet -> Value -> Eff effs TxId Source #

Make a payment from one wallet to another

nextSlot :: Member Waiting effs => Eff effs Slot Source #

Wait until the beginning of the next slot, returning the new slot number.

waitUntilSlot :: forall effs. Member Waiting effs => Slot -> Eff effs Slot Source #

waitUntilTime :: Member Waiting effs => POSIXTime -> Eff effs POSIXTime Source #

Wait until the slot where the given time falls into and return latest time we know has passed.

waitNSlots :: forall effs. Member Waiting effs => Natural -> Eff effs Slot Source #

Wait for a number of slots

waitNMilliSeconds :: forall effs. Member Waiting effs => DiffMilliSeconds -> Eff effs Slot Source #

Convert the given n milliseconds to a number of slots to wait.

Note: Currently, if n < length of a slot, then waitNMilliSeconds has no effect.

Inspecting the chain state

chainState :: forall effs. Member EmulatorControl effs => Eff effs ChainState Source #

Inspecting the agent states

agentState :: forall effs. Member EmulatorControl effs => Wallet -> Eff effs WalletState Source #

Throwing errors

throwError :: forall e (effs :: [Type -> Type]) a. Member (Error e) effs => e -> Eff effs a Source #

Throws an error carrying information of type e :: *.

data EmulatorRuntimeError Source #

Instances

Instances details
Eq EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Show EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Generic EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Associated Types

type Rep EmulatorRuntimeError :: Type -> Type Source #

ToJSON EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

FromJSON EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Pretty EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

type Rep EmulatorRuntimeError Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Running traces

data EmulatorConfig Source #

Constructors

EmulatorConfig 

Fields

runEmulatorStream :: forall effs a. EmulatorConfig -> EmulatorTrace a -> Stream (Of (LogMessage EmulatorEvent)) (Eff effs) (Maybe EmulatorErr, EmulatorState) Source #

Run a 'Trace Emulator', streaming the log messages as they arrive

data TraceConfig Source #

Options for how to set up and print the trace.

Constructors

TraceConfig 

Fields

Instances

Instances details
Default TraceConfig Source # 
Instance details

Defined in Plutus.Trace.Emulator

runEmulatorTrace :: EmulatorConfig -> EmulatorTrace () -> ([EmulatorEvent], Maybe EmulatorErr, EmulatorState) Source #

Run an emulator trace to completion, returning a tuple of the final state of the emulator, the events, and any error, if any.

data PrintEffect r where Source #

A very simple effect for interpreting the output printing done by the trace printing functions:

Constructors

PrintLn :: String -> PrintEffect () 

runEmulatorTraceEff :: forall effs. Member PrintEffect effs => TraceConfig -> EmulatorConfig -> EmulatorTrace () -> Eff effs () Source #

Run the emulator trace returning an effect that can be evaluated by interpreting the PrintEffects.

runEmulatorTraceIO :: EmulatorTrace () -> IO () Source #

Runs the trace with runEmulatorTrace, with default configuration that prints a selection of events to stdout.

Example:

>>> runEmulatorTraceIO (void $ Trace.waitNSlots 1)

Interpreter

interpretEmulatorTrace :: forall effs a. (Member MultiAgentEffect effs, Member MultiAgentControlEffect effs, Member (Error EmulatorRuntimeError) effs, Member ChainControlEffect effs, Member (LogMsg EmulatorEvent') effs, Member (State EmulatorState) effs) => EmulatorConfig -> EmulatorTrace a -> Eff effs () Source #

Interpret a 'Trace Emulator' action in the multi agent and emulated blockchain effects.