plutus-pab-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.PAB.Effects.Contract

Synopsis

Documentation

class PABContract contract where Source #

A class of contracts running in the PAB. The purpose of the type parameter contract is to allow for different ways of running contracts, for example: A compiled executable running in a separate process, or an "inline" contract that was compiled with the PAB and runs in the same process.

The associated type families correspond to the type arguments needed for the ContractRequest and ContractResponse types from State.

Associated Types

type ContractDef contract Source #

Any data needed to identify the contract. For example, the location of the executable.

type State contract Source #

Contract state type

Methods

serialisableState :: Proxy contract -> State contract -> ContractResponse Value Value PABResp PABReq Source #

Extract the serialisable state from the contract instance state.

Instances

Instances details
PABContract (Builtin a) Source # 
Instance details

Defined in Plutus.PAB.Effects.Contract.Builtin

Associated Types

type ContractDef (Builtin a) Source #

type State (Builtin a) Source #

requests :: forall contract. PABContract contract => State contract -> [Request PABReq] Source #

The open requests of the contract instance.

data ContractEffect t r where Source #

An effect for sending updates to contracts that implement PABContract

Constructors

ExportSchema 

Fields

InitialState 

Fields

UpdateContract 

Fields

exportSchema :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractDef t -> Eff effs [FunctionSchema FormSchema] Source #

Get the schema of a contract given its definition.

initialState :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractInstanceId -> ContractDef t -> Eff effs (State t) Source #

Get the initial state of a contract

updateContract :: forall t effs. (Member (ContractEffect t) effs, PABContract t) => ContractInstanceId -> ContractDef t -> State t -> Response PABResp -> Eff effs (State t) Source #

Send an update to the contract and return the new state.

Storing and retrieving contract state

data ContractStore t r where Source #

Storing and retrieving the state of a contract instance

Constructors

PutStartInstance 

Fields

PutState 

Fields

GetState 

Fields

PutStopInstance 

Fields

GetContracts 

Fields

putState :: forall t effs. Member (ContractStore t) effs => ContractActivationArgs (ContractDef t) -> ContractInstanceId -> State t -> Eff effs () Source #

Store the state of the contract instance

getState :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs (State t) Source #

Load the state of the contract instance

getDefinition :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs (Maybe (ContractActivationArgs (ContractDef t))) Source #

Get the definition of a running contract

getActiveContracts :: forall t effs. Member (ContractStore t) effs => Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) Source #

All active contracts with their definitions

getContracts :: forall t effs. Member (ContractStore t) effs => Maybe ContractActivityStatus -> Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) Source #

All contracts with their definitions by given status (all by default)

putStopInstance :: forall t effs. Member (ContractStore t) effs => ContractInstanceId -> Eff effs () Source #

Storing and retrieving definitions of contracts

data ContractDefinition t r where Source #

Storing and retrieving definitions of contracts. (Not all ts support this)

addDefinition :: forall t effs. Member (ContractDefinition t) effs => ContractDef t -> Eff effs () Source #

getDefinitions :: forall t effs. Member (ContractDefinition t) effs => Eff effs [ContractDef t] Source #