View on GitHub
File Changes
    -- ^ The state machine
    -> input
    -- ^ The input to apply to the state machine
-
    -> Contract schema e (Maybe state)
+
    -> Contract schema e state
runStep smc input = do
    let StateMachineInstance{stateMachine} = scInstance smc
    (NewState{newData=s, newValue=v, newConstraints}, inp, lookups) <- mkStep smc input
    pk <- ownPubKey
    let lookups' = lookups { Constraints.slOwnPubkey = Just $ pubKeyHash pk }
-
    if smFinal stateMachine s
-
        then do
-
            let txConstraints = TxConstraints{ txConstraints = newConstraints, txOwnInputs = [inp], txOwnOutputs = [] }
-
            utx <- either (throwing _ConstraintResolutionError) pure (Constraints.mkTx lookups' txConstraints)
-
            submitTxConfirmed utx
-
            pure Nothing
-
        else do
-
            let output        = OutputConstraint{ocData = s, ocValue = v}
-
                txConstraints = TxConstraints{ txConstraints = newConstraints, txOwnInputs = [inp], txOwnOutputs = [output] }
-
            utx <- either (throwing _ConstraintResolutionError) pure (Constraints.mkTx lookups' txConstraints)
-
            submitTxConfirmed utx
-
            pure $ Just s
+
        txConstraints =
+
            if smFinal stateMachine s
+
                then TxConstraints{ txConstraints = newConstraints, txOwnInputs = [inp], txOwnOutputs = [] }
+
                else
+
                    let output = OutputConstraint{ocData = s, ocValue = v}
+
                    in  TxConstraints{ txConstraints = newConstraints, txOwnInputs = [inp], txOwnOutputs = [output] }
+
    utx <- either (throwing _ConstraintResolutionError) pure (Constraints.mkTx lookups' txConstraints)
+
    submitTxConfirmed utx
+
    pure s

                      
-- | Initialise a state machine
runInitialise ::