plutus-pab-1.2.0.0
Safe Haskell None
Language Haskell2010

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.

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

InitialState

Fields

UpdateContract

Fields

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

DeleteState

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 WARNING : definition is misleading as this function is retrieving all instances (i.e., not only active ones), especially when the in memory database setting is used Indeed, handler defined in ContractStore ignores the status parameter given in GetContracts. Note also that a contract instance added in the db has active status set to True. This status is set to False only when the contract is explicitly stopped.

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)

Storing and retrieving definitions of contracts

data ContractDefinition t r where Source #

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