Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data Builtin a
- type ContractConstraints w schema error = (Monoid w, Forall (Output schema) ToJSON, Forall (Input schema) ToJSON, Forall (Input schema) FromJSON, ToJSON error, ToJSON w, FromJSON w, AllUniqueLabels (Input schema))
- data SomeBuiltin where
- SomeBuiltin :: forall contract w schema error a. (ContractConstraints w schema error, IsContract contract) => contract w schema error a -> SomeBuiltin
- data SomeBuiltinState a where
- SomeBuiltinState :: forall a w schema error b. ContractConstraints w schema error => ContractInstanceStateInternal w schema error b -> w -> SomeBuiltinState a
- newtype BuiltinHandler a = BuiltinHandler {
- contractHandler :: forall effs. (Member (Error PABError) effs, Member (LogMsg (PABMultiAgentMsg (Builtin a))) effs) => ContractEffect (Builtin a) ~> Eff effs
- handleBuiltin :: HasDefinitions a => BuiltinHandler a
- type family (l :: Row k) .\\ (r :: Row k) :: Row k where ...
- type family (l :: Row k) .\/ (r :: Row k) :: Row k where ...
- type EmptySchema = Empty :: Row a
- type Empty = 'R ('[] :: [LT a])
- getResponse :: forall a. SomeBuiltinState a -> ContractResponse Value Value PABResp PABReq
- fromResponse :: forall a effs. (Member (LogMsg (PABMultiAgentMsg (Builtin a))) effs, Member (Error PABError) effs) => ContractInstanceId -> SomeBuiltin -> ContractResponse Value Value PABResp PABReq -> Eff effs (SomeBuiltinState a)
- class HasDefinitions a where
- getDefinitions :: [a]
- getContract :: a -> SomeBuiltin
Documentation
Contracts that are built into the PAB (ie. compiled with it) and receive
an initial value of type a
.
We have a dummy constructor so that we can convert this datatype in Purescript with '(equal * (genericShow * mkSumType)) (Proxy @(Builtin A))'.
Instances
Eq (Builtin a) Source # | |
Generic (Builtin a) Source # | |
ToSchema t => ToSchema (Builtin t) Source # | |
Defined in Plutus.PAB.Effects.Contract.Builtin declareNamedSchema :: Proxy (Builtin t) -> Declare (Definitions Schema) NamedSchema | |
PABContract (Builtin a) Source # | |
type Rep (Builtin a) Source # | |
type ContractDef (Builtin a) Source # | |
Defined in Plutus.PAB.Effects.Contract.Builtin | |
type State (Builtin a) Source # | |
Defined in Plutus.PAB.Effects.Contract.Builtin |
type ContractConstraints w schema error = (Monoid w, Forall (Output schema) ToJSON, Forall (Input schema) ToJSON, Forall (Input schema) FromJSON, ToJSON error, ToJSON w, FromJSON w, AllUniqueLabels (Input schema)) Source #
data SomeBuiltin where Source #
Plutus contract with all parameters existentially quantified. Can be any contract that satisfies the
ContractConstraints
.
SomeBuiltin :: forall contract w schema error a. (ContractConstraints w schema error, IsContract contract) => contract w schema error a -> SomeBuiltin |
data SomeBuiltinState a where Source #
SomeBuiltinState | |
|
newtype BuiltinHandler a Source #
Defined in order to prevent type errors like: "Couldn't match type effs
with effs1
".
BuiltinHandler | |
|
handleBuiltin :: HasDefinitions a => BuiltinHandler a Source #
Handle the ContractEffect
for a builtin contract type with parameter
a
.
Extracting schemas from contracts
type family (l :: Row k) .\\ (r :: Row k) :: Row k where ... #
('R l :: Row a) .\\ ('R r :: Row a) = 'R (Diff l r) |
type EmptySchema = Empty :: Row a #
getResponse :: forall a. SomeBuiltinState a -> ContractResponse Value Value PABResp PABReq Source #
fromResponse :: forall a effs. (Member (LogMsg (PABMultiAgentMsg (Builtin a))) effs, Member (Error PABError) effs) => ContractInstanceId -> SomeBuiltin -> ContractResponse Value Value PABResp PABReq -> Eff effs (SomeBuiltinState a) Source #
Reconstruct a state from a serialised response by replaying back the actions.
class HasDefinitions a where Source #
Allows contract type a
to specify its available contract definitions.
Also, for each contract type, we specify its contract function and its
schemas.
:: [a] | Available contract definitions for a contract type |
:: a | |
-> SomeBuiltin | The actual contract function of contract type |