plutus-contract-1.2.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.Trace.Effects.RunContract

Synopsis

Documentation

data RunContract r where Source #

Run a Plutus contract (client side)

Constructors

CallEndpointP :: forall l ep w s e. (ContractConstraints s, HasEndpoint l ep s, ToJSON ep) => Proxy l -> ContractHandle w s e -> ep -> RunContract () 
GetContractState :: forall w s e. (ContractConstraints s, FromJSON e, FromJSON w, ToJSON w) => ContractHandle w s e -> RunContract (ContractInstanceState w s e ()) 

data StartContract r where Source #

Start a Plutus contract (client side)

Constructors

ActivateContract :: (IsContract contract, ContractConstraints s, Show e, FromJSON e, ToJSON e, ToJSON w, Monoid w, FromJSON w) => Wallet -> contract w s e a -> ContractInstanceTag -> StartContract (ContractHandle w s e) 

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 #

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 #

FromJSON ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Methods

parseJSON :: Value -> Parser ContractInstanceTag

parseJSONList :: Value -> Parser [ContractInstanceTag]

ToJSON ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Pretty ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

Methods

pretty :: ContractInstanceTag -> Doc ann

prettyList :: [ContractInstanceTag] -> Doc ann

type Rep ContractInstanceTag Source # 
Instance details

Defined in Plutus.Trace.Emulator.Types

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

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.

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 #

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.

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.

walletInstanceTag :: Wallet -> ContractInstanceTag Source #

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

handleRunContract :: forall effs effs2 a. (Member (State EmulatorThreads) effs2, Member (Error EmulatorRuntimeError) effs2, Member (Error EmulatorRuntimeError) effs, Member (LogMsg EmulatorEvent') effs, Member (State EmulatorThreads) effs, Member (Reader ThreadId) effs, Member (Yield (EmSystemCall effs2 EmulatorMessage a) (Maybe EmulatorMessage)) effs) => RunContract ~> Eff effs Source #

Handle the RunContract effect by running each contract instance in an emulator thread.

handleStartContract :: forall effs effs2 a. (Member (State EmulatorThreads) effs2, Member (Error EmulatorRuntimeError) effs2, Member MultiAgentEffect effs2, Member (LogMsg EmulatorEvent') effs2, Member ContractInstanceIdEff effs, Member (Yield (EmSystemCall effs2 EmulatorMessage a) (Maybe EmulatorMessage)) effs) => NetworkId -> StartContract ~> Eff effs Source #

Handle the StartContract effect by starting each contract instance in an emulator thread.

startContractThread :: forall w s e effs effs2 a. (Member (Yield (EmSystemCall effs2 EmulatorMessage a) (Maybe EmulatorMessage)) effs, Member (State EmulatorThreads) effs2, Member MultiAgentEffect effs2, Member (Error EmulatorRuntimeError) effs2, Member (LogMsg EmulatorEvent') effs2, ContractConstraints s, Show e, ToJSON e, ToJSON w, Monoid w) => Wallet -> ContractHandle w s e -> Eff effs (Maybe EmulatorMessage) Source #

Start a new thread for a contract instance (given by the handle). The thread runs in the context of the wallet.