plutus-pab-1.2.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 #

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

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

Methods

parseJSON :: Value -> Parser (ContractInstanceMsg t)

parseJSONList :: Value -> Parser [ContractInstanceMsg t]

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

Defined in Plutus.PAB.Core.ContractInstance.RequestHandlers

Methods

pretty :: ContractInstanceMsg t -> Doc ann

prettyList :: [ContractInstanceMsg t] -> Doc ann

ToJSON (ContractDef t) => ToJSON (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

Methods

toObject :: TracingVerbosity -> ContractInstanceMsg t -> Object

textTransformer :: ContractInstanceMsg t -> Object -> Text

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-1.2.0.0-LtxAAjtTYeqGloVmBPlsYv" '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 CardanoTx))))) :+: ((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.

type AppBackendConstraints t m effs = (LastMember m effs, MonadIO m, Member (Error PABError) effs, Member (LogMsg (ContractInstanceMsg t)) effs, Member ChainIndexQueryEffect effs, Member WalletEffect effs, Member NodeClientEffect effs, Member (LogMsg RequestHandlerLogMsg) effs, Member (LogObserve (LogMessage Text)) effs, Member (LogMsg TxBalanceMsg) effs, Member (Reader BlockchainEnv) effs, Member (ContractEffect t) effs, Member (ContractStore t) effs) Source #

Calling endpoints

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

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

Indexed block