View on GitHub
File Changes
import qualified Language.PlutusTx.AssocMap as Map
import           Language.PlutusTx.Lift     (makeLift)
import           Language.PlutusTx.Prelude  hiding ((<>))
-
import           Ledger                     (PubKeyHash (..), Slot (..), ValidatorHash)
+
import           Ledger                     (Address(..), PubKeyHash (..), Slot (..), ValidatorHash)
import           Ledger.Interval            (Extended (..), Interval (..), LowerBound (..), UpperBound (..))
import           Ledger.Scripts             (DataValue (..))
import           Ledger.Tx                  (TxOut (..), TxOutType (..))
validatePayments :: MarloweParams -> PendingTx -> [Payment] -> Bool
validatePayments MarloweParams{..} pendingTx txOutPayments = all checkValidPayment listOfPayments
  where
-
    collect :: Map Party Money -> PendingTxOut -> Map Party Money
-
    collect outputs PendingTxOut{..} =
-
        case pendingTxOutType of
-
            PubKeyTxOut pubKeyHash -> let
-
                party = PK pubKeyHash
-
                curValue = fromMaybe zero (Map.lookup party outputs)
-
                newValue = pendingTxOutValue + curValue
-
                in Map.insert party newValue outputs
-
            ScriptTxOut validatorHash dataValueHash | validatorHash == rolePayoutValidatorHash ->
+
    collect :: Map Party Money -> TxOut -> Map Party Money
+
    collect outputs TxOut{txOutAddress=PubKeyAddress pubKeyHash, txOutValue} =
+
        let
+
            party = PK pubKeyHash
+
            curValue = fromMaybe zero (Map.lookup party outputs)
+
            newValue = txOutValue + curValue
+
        in Map.insert party newValue outputs
+
    collect outputs TxOut{txOutAddress=ScriptAddress validatorHash, txOutValue, txOutType=PayToScript dataValueHash}
+
        | validatorHash == rolePayoutValidatorHash =
                case findData dataValueHash pendingTx of
                    Just (DataValue dv) ->
                        case PlutusTx.fromData dv of
                            Just (currency, role) | currency == rolesCurrency -> let
                                party = Role role
                                curValue = fromMaybe zero (Map.lookup party outputs)
-
                                newValue = pendingTxOutValue + curValue
+
                                newValue = txOutValue + curValue
                                in Map.insert party newValue outputs
                            _ -> outputs
                    Nothing -> outputs
-
            _ -> outputs
+
    collect outputs _ = outputs

                      
    collectPayments :: Map Party Money -> Payment -> Map Party Money
    collectPayments payments (Payment party money) = let
  where
    validateContinuation txOutPayments txOutState txOutContract =
        case getContinuingOutputs pendingTx of
-
            [PendingTxOut
-
                { pendingTxOutType = (ScriptTxOut _ dsh)
-
                , pendingTxOutValue = scriptOutputValue
+
            [TxOut
+
                { txOutType = (PayToScript dsh)
+
                , txOutValue = scriptOutputValue
                }] | Just (DataValue ds) <- findData dsh pendingTx ->

                      
                case PlutusTx.fromData ds of