plutus-pab-0.1.0.0
Safe HaskellNone
LanguageHaskell2010

Plutus.PAB.Core.ContractInstance

Synopsis

Documentation

data ContractInstanceMsg t Source #

Log messages about the contract instance

Instances

Instances details
Eq (ContractDef t) => Eq (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

Show (ContractDef t) => Show (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

Generic (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

Associated Types

type Rep (ContractInstanceMsg t) :: Type -> Type Source #

ToJSON (ContractDef t) => ToJSON (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

FromJSON (ContractDef t) => FromJSON (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

Pretty (ContractDef t) => Pretty (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

ToJSON (ContractDef t) => ToObject (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

type Rep (ContractInstanceMsg t) Source # 
Instance details

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

type Rep (ContractInstanceMsg t) = D1 ('MetaData "ContractInstanceMsg" "Plutus.PAB.Core.ContractInstance.RequestHandlers" "plutus-pab-0.1.0.0-1vc1rt5g5zvBlHvXKfwLQ7" 'False) ((((C1 ('MetaCons "ProcessFirstInboxMessage" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (Response PABResp))) :+: C1 ('MetaCons "SendingContractStateMessages" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Request PABReq])))) :+: (C1 ('MetaCons "LookingUpStateOfContractInstance" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "CurrentIteration" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID)) :+: C1 ('MetaCons "InboxMessageDoesntMatchIteration" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID))))) :+: ((C1 ('MetaCons "InboxMessageMatchesIteration" 'PrefixI 'False) (U1 :: Type -> Type) :+: (C1 ('MetaCons "InvokingContractUpdate" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ObtainedNewState" 'PrefixI 'False) (U1 :: Type -> Type))) :+: (C1 ('MetaCons "ContractLog" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: (C1 ('MetaCons "UpdatedContract" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 IterationID)) :+: C1 ('MetaCons "LookingUpContract" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ContractDef t))))))) :+: (((C1 ('MetaCons "InitialisingContract" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ContractDef t)) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId)) :+: (C1 ('MetaCons "InitialPABResp" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (PartiallyDecodedResponse PABReq))) :+: C1 ('MetaCons "ActivatedContractInstance" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 (ContractDef t)) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Wallet) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId))))) :+: (C1 ('MetaCons "RunRequestHandler" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)) :+: (C1 ('MetaCons "RunRequestHandlerDidNotHandleAnyEvents" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "StoringSignedTx" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Tx))))) :+: ((C1 ('MetaCons "CallingEndpoint" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 String) :*: (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value))) :+: (C1 ('MetaCons "ProcessContractInbox" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId)) :+: C1 ('MetaCons "HandlingRequest" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 RequestHandlerLogMsg)))) :+: (C1 ('MetaCons "HandlingRequests" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 ContractInstanceId) :*: S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Request PABReq])) :+: (C1 ('MetaCons "BalancingTx" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 TxBalanceMsg)) :+: C1 ('MetaCons "NotificationFailed" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 NotificationError)))))))

activateContractSTM :: forall t m appBackend effs. (Member (LogMsg (ContractInstanceMsg t)) effs, Member UUIDEffect effs, Member (ContractEffect t) effs, Member (ContractStore t) effs, Member (Reader InstancesState) effs, PABContract t, AppBackendConstraints t m appBackend, LastMember m (Reader ContractInstanceId ': appBackend), LastMember m effs) => (ContractInstanceId -> Eff appBackend ~> IO) -> ContractActivationArgs (ContractDef t) -> Eff effs ContractInstanceId Source #

Create a new instance of the contract

activateContractSTM' :: forall t m appBackend effs. (Member (LogMsg (ContractInstanceMsg t)) effs, Member (ContractStore t) effs, Member (Reader InstancesState) effs, PABContract t, AppBackendConstraints t m appBackend, LastMember m (Reader ContractInstanceId ': appBackend), LastMember m effs) => ContractInstanceState t -> ContractInstanceId -> (ContractInstanceId -> Eff appBackend ~> IO) -> ContractActivationArgs (ContractDef t) -> Eff effs ContractInstanceId Source #

Create a new instance of the contract, but where the activeContractInstanceId and the initial state are provided.

initContractInstanceState :: forall t effs. (Member UUIDEffect effs, Member (ContractEffect t) effs, PABContract t) => ContractActivationArgs (ContractDef t) -> Eff effs (ContractInstanceId, ContractInstanceState t) Source #

Build a new ContractInstanceState and return it, along with the corresponding new intsance id.

data ContractInstanceState t Source #

Container for holding a few bits of state related to the contract instance that we may want to pass in.

updateState :: forall m effs. (LastMember m effs, MonadIO m, Member (Reader InstanceState) effs) => ContractResponse Value Value PABResp PABReq -> Eff effs () Source #

Update the TVars in the InstanceState with data from the list of requests.

STM instances

startSTMInstanceThread :: forall t m appBackend effs. (LastMember m effs, PABContract t, AppBackendConstraints t m appBackend, LastMember m (Reader InstanceState ': (Reader ContractInstanceId ': appBackend))) => (ContractInstanceId -> Eff appBackend ~> IO) -> ContractActivationArgs (ContractDef t) -> ContractInstanceId -> Eff effs InstanceState Source #

Start the thread for the contract instance

startContractInstanceThread' :: forall t m appBackend effs. (Member (Reader InstancesState) effs, PABContract t, AppBackendConstraints t m appBackend, LastMember m (Reader ContractInstanceId ': appBackend), LastMember m effs) => ContractInstanceState t -> ContractInstanceId -> (ContractInstanceId -> Eff appBackend ~> IO) -> ContractActivationArgs (ContractDef t) -> Eff effs ContractInstanceId Source #

Spin up the STM Instance thread for the provided contract and add it to the STM instance state.

Calling endpoints

callEndpointOnInstance :: InstancesState -> EndpointDescription -> Value -> ContractInstanceId -> STM (Maybe NotificationError) Source #

Call an endpoint on a contract instance. Fail immediately if the endpoint is not active.

Indexed block