Skip to content

Commit

Permalink
Rename some constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mueller committed May 9, 2021
1 parent 1f3523f commit 9d517e4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions plutus-pab/src/Plutus/PAB/Db/Eventful/ContractStore.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ handleContractStore = \case
case Map.lookup i contractState of
Nothing -> throwError $ ContractInstanceNotFound i
Just k -> pure k
ActiveContracts ->
GetActiveContracts ->
runGlobalQuery (Query.contractDefinition @(ContractDef t))
StartInstance def i ->
PutStartInstance def i ->
void $ runCommand @() @(PABEvent (ContractDef t))
Command.startContractInstance
PABEventSource
(def, i)
StopInstance i ->
PutStopInstance i ->
void $ runCommand @() @(PABEvent (ContractDef t))
Command.stopContractInstance
PABEventSource
Expand Down
12 changes: 6 additions & 6 deletions plutus-pab/src/Plutus/PAB/Effects/Contract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ updateContract i def state request =

-- | Storing and retrieving the state of a contract instance
data ContractStore t r where
StartInstance :: ContractActivationArgs (ContractDef t) -> ContractInstanceId -> ContractStore t ()
PutState :: ContractActivationArgs (ContractDef t) -> ContractInstanceId -> State t -> ContractStore t ()
GetState :: ContractInstanceId -> ContractStore t (State t)
StopInstance :: ContractInstanceId -> ContractStore t ()
ActiveContracts :: ContractStore t (Map ContractInstanceId (ContractActivationArgs (ContractDef t)))
PutStartInstance :: ContractActivationArgs (ContractDef t) -> ContractInstanceId -> ContractStore t () -- ^ Record the starting of a new contract instance
PutState :: ContractActivationArgs (ContractDef t) -> ContractInstanceId -> State t -> ContractStore t () -- ^ Record the updated state of the contract instance
GetState :: ContractInstanceId -> ContractStore t (State t) -- ^ Retrieve the last recorded state of the contract instance
PutStopInstance :: ContractInstanceId -> ContractStore t () -- ^ Record the fact that a contract instance has stopped
GetActiveContracts :: ContractStore t (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) -- ^ Get all active contracts with their activation args

-- | Store the state of the contract instance
putState ::
Expand Down Expand Up @@ -155,7 +155,7 @@ getActiveContracts ::
)
=> Eff effs (Map ContractInstanceId (ContractActivationArgs (ContractDef t)))
getActiveContracts =
let command :: ContractStore t (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) = ActiveContracts
let command :: ContractStore t (Map ContractInstanceId (ContractActivationArgs (ContractDef t))) = GetActiveContracts
in send command

-- | Get the definition of a running contract
Expand Down
6 changes: 3 additions & 3 deletions plutus-pab/src/Plutus/PAB/Simulator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,11 @@ handleContractStore = \case
case result of
Just s -> pure s
Nothing -> throwError (ContractInstanceNotFound instanceId)
Contract.ActiveContracts -> do
Contract.GetActiveContracts -> do
instancesTVar <- view instances <$> (Core.askUserEnv @t @(SimulatorState t))
fmap _contractDef <$> liftIO (STM.readTVarIO instancesTVar)
Contract.StartInstance{} -> pure ()
Contract.StopInstance{} -> pure ()
Contract.PutStartInstance{} -> pure ()
Contract.PutStopInstance{} -> pure ()

render :: forall a. Pretty a => a -> Text
render = Render.renderStrict . layoutPretty defaultLayoutOptions . pretty
Expand Down

0 comments on commit 9d517e4

Please sign in to comment.