View on GitHub
File Changes
            marloweState = emptyState slot }
        ds = DataValue $ PlutusTx.toData marloweData

                      
-
        deposit = adaValueOf 1
-

                      
-
    (payment, change) <- createPaymentWithChange deposit
-
    let o = scriptTxOut deposit validator ds
+
    let payValue = adaValueOf 1
+
    (payment, change) <- createPaymentWithChange payValue
+
    let o = scriptTxOut P.zero validator ds
        slotRange = interval slot (slot + 10)
-
        outputs = o : maybeToList change
+
        outputs = o : (pubKeyTxOut payValue creator) : maybeToList change

                      
    tx <- createTxAndSubmit slotRange payment outputs [ds]
    return (marloweData, tx)
    -> [Input]
    -> m (MarloweData, Tx)
applyInputs tx [email protected]{..} inputs = do
-
    let depositAmount = adaValueOf 1
-
        depositPayment = Payment marloweCreator depositAmount
-
        redeemer = mkRedeemer inputs
+
    let redeemer = mkRedeemer inputs
        validator = validatorScript marloweCreator
        dataValue = DataValue (PlutusTx.toData marloweData)
        address = scriptAddress validator
                    marloweState = txOutState }

                      
            let deducedTxOutputs = case txOutContract of
-
                    Close -> txPaymentOuts (depositPayment : txOutPayments)
+
                    Close -> txPaymentOuts txOutPayments
                    _ -> let
                        payouts = txPaymentOuts txOutPayments
                        totalPayouts = foldMap txOutValue payouts
-
                        finalBalance = totalIncome P.- totalPayouts P.+ depositAmount
+
                        finalBalance = totalIncome P.- totalPayouts
                        dataValue = DataValue (PlutusTx.toData marloweData)
                        scriptOut = scriptTxOut finalBalance validator dataValue
                        in scriptOut : payouts

                      

                      
{-| Ensure that 'pendingTx' contains expected payments.   -}
-
validateTxOutputs :: PendingTx -> Party -> Money -> TransactionOutput -> Bool
-
validateTxOutputs pendingTx creator deposit expectedTxOutputs = case expectedTxOutputs of
+
validateTxOutputs :: PendingTx -> Party -> TransactionOutput -> Bool
+
validateTxOutputs pendingTx creator expectedTxOutputs = case expectedTxOutputs of
    TransactionOutput {txOutPayments, txOutState, txOutContract} ->
        case txOutContract of
-
            Close -> let
-
                -- if it's a last transaction, don't expect any continuation,
-
                -- everything is payed out, including initial deposit.
-
                payments = Payment creator deposit : txOutPayments
-
                in validatePayments pendingTx payments
+
            -- if it's a last transaction, don't expect any continuation,
+
            -- everything is payed out.
+
            Close -> validatePayments pendingTx txOutPayments
            -- otherwise check the continuation
            _ -> case getContinuingOutputs pendingTx of
                    [PendingTxOut
                                    && txOutState == expectedState
                                    && txOutContract == expectedContract
                                outputBalance = totalBalance (accounts txOutState)
-
                                outputBalanceOk = scriptOutputValue == (outputBalance + deposit)
+
                                outputBalanceOk = scriptOutputValue == outputBalance
                                in  outputBalanceOk
                                    && validContract
                                    && validatePayments pendingTx txOutPayments
    -- accounts must be positive, and we checked it above
    inputBalance = totalBalance (accounts marloweState)

                      
-
    -- ensure that a contract TxOut has at least what it suppose to have
-
    balancesOk = inputBalance `Val.leq` scriptInValue
-

                      
-
    -- calculate contract creation deposit
-
    deposit = scriptInValue - inputBalance
+
    -- ensure that a contract TxOut has what it suppose to have
+
    balancesOk = inputBalance == scriptInValue

                      
    preconditionsOk = checkCreator
        && positiveBalances
    txInput = TransactionInput { txInterval = slotInterval, txInputs = inputs }
    expectedTxOutputs = computeTransaction txInput marloweState marloweContract

                      
-
    outputOk = validateTxOutputs pendingTx creator deposit expectedTxOutputs
+
    outputOk = validateTxOutputs pendingTx creator expectedTxOutputs

                      
    in preconditionsOk && outputOk