Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Emulator
- type EmulatorTrace = Eff EmulatorEffects
- type EmulatorEffects = StartContract ': BaseEmulatorEffects
- type BaseEmulatorEffects = [RunContract, Assert, Waiting, EmulatorControl, EmulatedWalletAPI, LogMsg String, Error EmulatorRuntimeError]
- data EmulatorErr
- = WalletErr WalletAPIError
- | ChainIndexErr ChainIndexError
- | AssertionErr AssertionError
- | InstanceErr EmulatorRuntimeError
- | ExitWasNeverCalled
- data ContractHandle w s e = ContractHandle {
- chContract :: Contract w s e ()
- chInstanceId :: ContractInstanceId
- chInstanceTag :: ContractInstanceTag
- chNetworkId :: NetworkId
- data ContractInstanceTag
- type ContractConstraints s = (Forall (Output s) Unconstrained1, Forall (Input s) Unconstrained1, AllUniqueLabels (Input s), AllUniqueLabels (Output s), Forall (Input s) FromJSON, Forall (Input s) ToJSON, Forall (Output s) FromJSON, Forall (Output s) ToJSON)
- assert :: forall effs. Member Assert effs => String -> (EmulatorState -> Bool) -> Eff effs ()
- 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)
- 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)
- walletInstanceTag :: Wallet -> ContractInstanceTag
- 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 ()
- 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 ())
- observableState :: forall w s e effs. (Member RunContract effs, ContractConstraints s, FromJSON e, FromJSON w, ToJSON w) => ContractHandle w s e -> Eff effs w
- activeEndpoints :: forall w s e effs. (Member RunContract effs, ContractConstraints s, FromJSON e, FromJSON w, ToJSON w) => ContractHandle w s e -> Eff effs [ActiveEndpoint]
- liftWallet :: forall a. forall effs. Member EmulatedWalletAPI effs => Wallet -> Eff ('(:) WalletEffect ('(:) (Error WalletAPIError) ('(:) (LogMsg Text) ('(:) (LogMsg RequestHandlerLogMsg) ('[] :: [Type -> Type]))))) a -> Eff effs a
- payToWallet :: forall effs. Member EmulatedWalletAPI effs => Wallet -> Wallet -> Value -> Eff effs TxId
- nextSlot :: Member Waiting effs => Eff effs Slot
- waitUntilSlot :: forall effs. Member Waiting effs => Slot -> Eff effs Slot
- waitUntilTime :: Member Waiting effs => POSIXTime -> Eff effs POSIXTime
- waitNSlots :: forall effs. Member Waiting effs => Natural -> Eff effs Slot
- waitNMilliSeconds :: forall effs. Member Waiting effs => DiffMilliSeconds -> Eff effs Slot
- freezeContractInstance :: forall effs. Member EmulatorControl effs => ContractInstanceId -> Eff effs ()
- thawContractInstance :: forall effs. Member EmulatorControl effs => ContractInstanceId -> Eff effs ()
- setSigningProcess :: forall effs. Member EmulatorControl effs => Wallet -> Maybe SigningProcess -> Eff effs ()
- chainState :: forall effs. Member EmulatorControl effs => Eff effs ChainState
- getSlotConfig :: forall effs. Member EmulatorControl effs => Eff effs SlotConfig
- chainNewestFirst :: Lens' ChainState Blockchain
- txPool :: Lens' ChainState TxPool
- index :: Lens' ChainState UtxoIndex
- chainCurrentSlot :: Lens' ChainState Slot
- agentState :: forall effs. Member EmulatorControl effs => Wallet -> Eff effs WalletState
- ownPaymentPrivateKey :: WalletState -> PaymentPrivateKey
- nodeClient :: Lens' WalletState NodeClientState
- signingProcess :: Lens' WalletState (Maybe SigningProcess)
- throwError :: forall e (effs :: [Type -> Type]) a. Member (Error e) effs => e -> Eff effs a
- data EmulatorRuntimeError
- data EmulatorConfig = EmulatorConfig {}
- initialChainState :: Lens' EmulatorConfig InitialChainState
- params :: Lens' EmulatorConfig Params
- runEmulatorStream :: forall effs a. EmulatorConfig -> EmulatorTrace a -> Stream (Of (LogMessage EmulatorEvent)) (Eff effs) (Either EmulatorErr a, EmulatorState)
- data TraceConfig = TraceConfig {
- traceConfigShowEvent :: LogMessage EmulatorEvent -> Maybe String
- traceConfigOutputHandle :: Handle
- traceConfigMinLogLevel :: LogLevel
- traceConfigShowEventExample :: LogMessage EmulatorEvent -> Maybe String
- runEmulatorTrace :: TraceConfig -> EmulatorConfig -> EmulatorTrace a -> ([LogMessage EmulatorEvent], Either EmulatorErr a, EmulatorState)
- evalEmulatorTrace :: TraceConfig -> EmulatorConfig -> EmulatorTrace a -> Either EmulatorErr a
- data PrintEffect r where
- PrintLn :: String -> PrintEffect ()
- runEmulatorTraceEff :: forall effs. Member PrintEffect effs => TraceConfig -> EmulatorConfig -> EmulatorTrace () -> Eff effs ()
- runEmulatorTraceIO :: EmulatorTrace () -> IO ()
- runEmulatorTraceIO' :: TraceConfig -> EmulatorConfig -> EmulatorTrace () -> IO ()
- 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 (Maybe a)
Documentation
type EmulatorTrace = Eff EmulatorEffects Source #
type EmulatorEffects = StartContract ': BaseEmulatorEffects Source #
type BaseEmulatorEffects = [RunContract, Assert, Waiting, EmulatorControl, EmulatedWalletAPI, LogMsg String, Error EmulatorRuntimeError] Source #
data EmulatorErr Source #
WalletErr WalletAPIError | |
ChainIndexErr ChainIndexError | |
AssertionErr AssertionError | |
InstanceErr EmulatorRuntimeError | |
ExitWasNeverCalled |
Instances
Show EmulatorErr Source # | |
Defined in Wallet.Emulator.Stream |
data ContractHandle w s e Source #
A reference to a running contract in the emulator.
ContractHandle | |
|
data ContractInstanceTag Source #
A user-defined tag for a contract instance. Used to find the instance's log messages in the emulator log.
Instances
type ContractConstraints s = (Forall (Output s) Unconstrained1, Forall (Input s) Unconstrained1, AllUniqueLabels (Input s), AllUniqueLabels (Output s), Forall (Input s) FromJSON, Forall (Input s) ToJSON, Forall (Output s) FromJSON, Forall (Output s) ToJSON) Source #
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) ('(:) (LogMsg RequestHandlerLogMsg) ('[] :: [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.
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.
freezeContractInstance :: forall effs. Member EmulatorControl effs => ContractInstanceId -> Eff effs () Source #
thawContractInstance :: forall effs. Member EmulatorControl effs => ContractInstanceId -> Eff effs () Source #
Inspecting the chain state
setSigningProcess :: forall effs. Member EmulatorControl effs => Wallet -> Maybe SigningProcess -> Eff effs () Source #
chainState :: forall effs. Member EmulatorControl effs => Eff effs ChainState Source #
getSlotConfig :: forall effs. Member EmulatorControl effs => Eff effs SlotConfig Source #
chainNewestFirst :: Lens' ChainState Blockchain #
chainCurrentSlot :: Lens' ChainState Slot #
Inspecting the agent states
agentState :: forall effs. Member EmulatorControl effs => Wallet -> Eff effs WalletState Source #
ownPaymentPrivateKey :: WalletState -> PaymentPrivateKey Source #
nodeClient :: Lens' WalletState NodeClientState Source #
signingProcess :: Lens' WalletState (Maybe SigningProcess) Source #
Throwing errors
throwError :: forall e (effs :: [Type -> Type]) a. Member (Error e) effs => e -> Eff effs a #
data EmulatorRuntimeError Source #
ThreadIdNotFound ContractInstanceId | |
InstanceIdNotFound Wallet | |
EmulatorJSONDecodingError String Value | |
GenericError String | |
EmulatedWalletError WalletAPIError | |
AssertionError String |
Instances
Running traces
data EmulatorConfig Source #
EmulatorConfig | |
|
Instances
Eq EmulatorConfig Source # | |
Defined in Wallet.Emulator.Stream (==) :: EmulatorConfig -> EmulatorConfig -> Bool Source # (/=) :: EmulatorConfig -> EmulatorConfig -> Bool Source # | |
Show EmulatorConfig Source # | |
Defined in Wallet.Emulator.Stream | |
Default EmulatorConfig Source # | |
Defined in Wallet.Emulator.Stream |
params :: Lens' EmulatorConfig Params Source #
runEmulatorStream :: forall effs a. EmulatorConfig -> EmulatorTrace a -> Stream (Of (LogMessage EmulatorEvent)) (Eff effs) (Either EmulatorErr a, 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.
TraceConfig | |
|
Instances
Default TraceConfig Source # | |
Defined in Plutus.Trace.Emulator def :: TraceConfig |
traceConfigShowEventExample :: LogMessage EmulatorEvent -> Maybe String Source #
Some example of how to configure the traceConfigShowEvent
.
runEmulatorTrace :: TraceConfig -> EmulatorConfig -> EmulatorTrace a -> ([LogMessage EmulatorEvent], Either EmulatorErr a, 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.
evalEmulatorTrace :: TraceConfig -> EmulatorConfig -> EmulatorTrace a -> Either EmulatorErr a Source #
data PrintEffect r where Source #
A very simple effect for interpreting the output printing done by the trace printing functions:
runEmulatorTraceEff
runEmulatorTraceIO
runEmulatorTraceIOWithConfig
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 PrintEffect
s.
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)
runEmulatorTraceIO' :: TraceConfig -> EmulatorConfig -> EmulatorTrace () -> IO () Source #
Deprecated: Renamed to runEmulatorTraceIOWithConfig
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 (Maybe a) Source #
Interpret a 'Trace Emulator' action in the multi agent and emulated blockchain effects.