@@ -145,7 +145,7 @@ checkCollectCom ::
145
145
Bool
146
146
checkCollectCom ctx@ ScriptContext {scriptContextTxInfo = txInfo} (contestationPeriod, parties, headId) =
147
147
mustCollectUtxoHash
148
- && mustNotChangeParameters
148
+ && mustNotChangeParameters (parties', parties) (contestationPeriod', contestationPeriod) (headId', headId)
149
149
&& mustCollectAllValue
150
150
-- XXX: Is this really needed? If yes, why not check on the output?
151
151
&& traceIfFalse $ (errorCode STNotSpent ) (hasST headId val)
@@ -157,12 +157,6 @@ checkCollectCom ctx@ScriptContext{scriptContextTxInfo = txInfo} (contestationPer
157
157
traceIfFalse $ (errorCode IncorrectUtxoHash ) $
158
158
utxoHash == hashPreSerializedCommits collectedCommits
159
159
160
- mustNotChangeParameters =
161
- traceIfFalse $ (errorCode ChangedParameters ) $
162
- parties' == parties
163
- && contestationPeriod' == contestationPeriod
164
- && headId' == headId
165
-
166
160
mustCollectAllValue =
167
161
traceIfFalse $ (errorCode NotAllValueCollected ) $
168
162
-- NOTE: Instead of checking the head output val' against all collected
@@ -221,7 +215,7 @@ checkCollectCom ctx@ScriptContext{scriptContextTxInfo = txInfo} (contestationPer
221
215
-- if it is there return the committed utxo
222
216
commitDatum :: TxOut -> [Commit ]
223
217
commitDatum input = do
224
- let datum = getTxOutDatum input
218
+ let ! datum = getTxOutDatum input
225
219
case fromBuiltinData @ Commit. DatumType $ getDatum datum of
226
220
Just (_party, commits, _headId) ->
227
221
commits
@@ -238,18 +232,12 @@ checkDecrement ::
238
232
Integer ->
239
233
Bool
240
234
checkDecrement ctx@ ScriptContext {scriptContextTxInfo = txInfo} prevParties prevSnapshotNumber prevCperiod prevHeadId signature numberOfDecommitOutputs =
241
- mustNotChangeParameters
235
+ mustNotChangeParameters (prevParties, nextParties) (prevCperiod, nextCperiod) (prevHeadId, nextHeadId)
242
236
&& checkSnapshot
243
237
&& checkSnapshotSignature
244
238
&& mustBeSignedByParticipant ctx prevHeadId
245
239
&& mustDecreaseValue
246
240
where
247
- mustNotChangeParameters =
248
- traceIfFalse $ (errorCode ChangedParameters ) $
249
- prevHeadId == nextHeadId
250
- && prevParties == nextParties
251
- && prevCperiod == nextCperiod
252
-
253
241
checkSnapshot =
254
242
traceIfFalse $ (errorCode SnapshotNumberMismatch ) $
255
243
nextSnapshotNumber > prevSnapshotNumber
@@ -319,7 +307,7 @@ checkClose ctx parties initialUtxoHash sig cperiod headPolicyId =
319
307
&& mustBeSignedByParticipant ctx headPolicyId
320
308
&& mustInitializeContesters
321
309
&& mustPreserveValue
322
- && mustNotChangeParameters
310
+ && mustNotChangeParameters (parties', parties) (cperiod', cperiod) (headId', headPolicyId)
323
311
where
324
312
mustPreserveValue =
325
313
traceIfFalse $ (errorCode HeadValueIsNotPreserved ) $
@@ -370,12 +358,6 @@ checkClose ctx parties initialUtxoHash sig cperiod headPolicyId =
370
358
LowerBound (Finite t) _ -> t
371
359
_InfiniteBound -> traceError $ (errorCode InfiniteLowerBound )
372
360
373
- mustNotChangeParameters =
374
- traceIfFalse $ (errorCode ChangedParameters ) $
375
- headId' == headPolicyId
376
- && parties' == parties
377
- && cperiod' == cperiod
378
-
379
361
mustInitializeContesters =
380
362
traceIfFalse $ (errorCode ContestersNonEmpty ) $
381
363
null contesters'
@@ -428,7 +410,7 @@ checkContest ctx contestationDeadline contestationPeriod parties closedSnapshotN
428
410
&& mustBeWithinContestationPeriod
429
411
&& mustUpdateContesters
430
412
&& mustPushDeadline
431
- && mustNotChangeParameters
413
+ && mustNotChangeParameters (parties', parties) (contestationPeriod', contestationPeriod) (headId', headId)
432
414
&& mustPreserveValue
433
415
where
434
416
mustPreserveValue =
@@ -453,12 +435,6 @@ checkContest ctx contestationDeadline contestationPeriod parties closedSnapshotN
453
435
time <= contestationDeadline
454
436
_ -> traceError $ (errorCode ContestNoUpperBoundDefined )
455
437
456
- mustNotChangeParameters =
457
- traceIfFalse $ (errorCode ChangedParameters ) $
458
- parties' == parties
459
- && headId' == headId
460
- && contestationPeriod' == contestationPeriod
461
-
462
438
mustPushDeadline =
463
439
if length contesters' == length parties'
464
440
then
@@ -564,6 +540,18 @@ getHeadAddress :: ScriptContext -> Address
564
540
getHeadAddress = txOutAddress . txInInfoResolved . getHeadInput
565
541
{-# INLINEABLE getHeadAddress #-}
566
542
543
+ mustNotChangeParameters ::
544
+ ([Party ], [Party ]) ->
545
+ (ContestationPeriod , ContestationPeriod ) ->
546
+ (CurrencySymbol , CurrencySymbol ) ->
547
+ Bool
548
+ mustNotChangeParameters (parties', parties) (contestationPeriod', contestationPeriod) (headId', headId) =
549
+ traceIfFalse $ (errorCode ChangedParameters ) $
550
+ parties' == parties
551
+ && contestationPeriod' == contestationPeriod
552
+ && headId' == headId
553
+ {-# INLINEABLE mustNotChangeParameters #-}
554
+
567
555
-- XXX: We might not need to distinguish between the three cases here.
568
556
mustBeSignedByParticipant ::
569
557
ScriptContext ->
@@ -643,7 +631,7 @@ hashTxOuts =
643
631
-- | Check if 'TxOut' contains the PT token.
644
632
hasPT :: CurrencySymbol -> TxOut -> Bool
645
633
hasPT headCurrencySymbol txOut =
646
- let pts = findParticipationTokens headCurrencySymbol (txOutValue txOut)
634
+ let ! pts = findParticipationTokens headCurrencySymbol (txOutValue txOut)
647
635
in length pts == 1
648
636
{-# INLINEABLE hasPT #-}
649
637
0 commit comments