@@ -50,7 +50,6 @@ import Hydra.Cardano.Api (
50
50
txOutValue ,
51
51
txSpendingUTxO ,
52
52
pattern ByronAddressInEra ,
53
- pattern PlutusScriptSerialised ,
54
53
pattern ShelleyAddressInEra ,
55
54
pattern TxIn ,
56
55
pattern TxOut ,
@@ -394,23 +393,17 @@ abort ::
394
393
abort ctx seedTxIn spendableUTxO committedUTxO = do
395
394
headUTxO <-
396
395
maybe (Left CannotFindHeadOutputToAbort ) pure $
397
- UTxO. find (isScriptTxOut headScript ) utxoOfThisHead'
396
+ UTxO. find (isScriptTxOut Head. validatorScript ) utxoOfThisHead'
398
397
399
398
abortTx committedUTxO scriptRegistry ownVerificationKey headUTxO headTokenScript initials commits
400
399
where
401
400
utxoOfThisHead' = utxoOfThisHead (headPolicyId seedTxIn) spendableUTxO
402
401
403
402
initials =
404
- UTxO. toMap $ UTxO. filter (isScriptTxOut initialScript ) utxoOfThisHead'
403
+ UTxO. toMap $ UTxO. filter (isScriptTxOut initialValidatorScript ) utxoOfThisHead'
405
404
406
405
commits =
407
- UTxO. toMap $ UTxO. filter (isScriptTxOut commitScript) utxoOfThisHead'
408
-
409
- commitScript = PlutusScriptSerialised commitValidatorScript
410
-
411
- headScript = PlutusScriptSerialised Head. validatorScript
412
-
413
- initialScript = PlutusScriptSerialised initialValidatorScript
406
+ UTxO. toMap $ UTxO. filter (isScriptTxOut commitValidatorScript) utxoOfThisHead'
414
407
415
408
headTokenScript = mkHeadTokenScript seedTxIn
416
409
@@ -437,15 +430,11 @@ collect ::
437
430
collect ctx headId headParameters utxoToCollect spendableUTxO = do
438
431
pid <- headIdToPolicyId headId ?> InvalidHeadIdInCollect {headId}
439
432
let utxoOfThisHead' = utxoOfThisHead pid spendableUTxO
440
- headUTxO <- UTxO. find (isScriptTxOut headScript ) utxoOfThisHead' ?> CannotFindHeadOutputToCollect
441
- let commits = UTxO. toMap $ UTxO. filter (isScriptTxOut commitScript ) utxoOfThisHead'
433
+ headUTxO <- UTxO. find (isScriptTxOut Head. validatorScript ) utxoOfThisHead' ?> CannotFindHeadOutputToCollect
434
+ let commits = UTxO. toMap $ UTxO. filter (isScriptTxOut commitValidatorScript ) utxoOfThisHead'
442
435
pure $
443
436
collectComTx networkId scriptRegistry ownVerificationKey headId headParameters headUTxO commits utxoToCollect
444
437
where
445
- headScript = PlutusScriptSerialised Head. validatorScript
446
-
447
- commitScript = PlutusScriptSerialised commitValidatorScript
448
-
449
438
ChainContext {networkId, ownVerificationKey, scriptRegistry} = ctx
450
439
451
440
data IncrementTxError
@@ -473,11 +462,11 @@ increment ::
473
462
increment ctx spendableUTxO headId headParameters incrementingSnapshot depositTxId upperValiditySlot = do
474
463
pid <- headIdToPolicyId headId ?> InvalidHeadIdInIncrement {headId}
475
464
let utxoOfThisHead' = utxoOfThisHead pid spendableUTxO
476
- headUTxO <- UTxO. find (isScriptTxOut headScript ) utxoOfThisHead' ?> CannotFindHeadOutputInIncrement
465
+ headUTxO <- UTxO. find (isScriptTxOut Head. validatorScript ) utxoOfThisHead' ?> CannotFindHeadOutputInIncrement
477
466
(depositedIn, depositedOut) <-
478
467
UTxO. findBy
479
468
( \ (TxIn txid _, txout) ->
480
- isScriptTxOut depositScript txout && txid == depositTxId
469
+ isScriptTxOut depositValidatorScript txout && txid == depositTxId
481
470
)
482
471
spendableUTxO
483
472
?> CannotFindDepositOutputInIncrement {depositTxId}
@@ -489,9 +478,6 @@ increment ctx spendableUTxO headId headParameters incrementingSnapshot depositTx
489
478
Left SnapshotIncrementUTxOIsNull
490
479
| otherwise -> Right $ incrementTx scriptRegistry ownVerificationKey headId headParameters headUTxO sn (UTxO. singleton (depositedIn, depositedOut)) upperValiditySlot sigs
491
480
where
492
- headScript = PlutusScriptSerialised Head. validatorScript
493
- depositScript = PlutusScriptSerialised depositValidatorScript
494
-
495
481
Snapshot {utxoToCommit} = sn
496
482
497
483
(sn, sigs) =
@@ -523,14 +509,12 @@ decrement ::
523
509
decrement ctx spendableUTxO headId headParameters decrementingSnapshot = do
524
510
pid <- headIdToPolicyId headId ?> InvalidHeadIdInDecrement {headId}
525
511
let utxoOfThisHead' = utxoOfThisHead pid spendableUTxO
526
- headUTxO@ (_, headOut) <- UTxO. find (isScriptTxOut headScript ) utxoOfThisHead' ?> CannotFindHeadOutputInDecrement
512
+ headUTxO@ (_, headOut) <- UTxO. find (isScriptTxOut Head. validatorScript ) utxoOfThisHead' ?> CannotFindHeadOutputInDecrement
527
513
let balance = txOutValue headOut <> negateValue decommitValue
528
514
when (isNegative balance) $
529
515
Left DecrementValueNegative
530
516
Right $ decrementTx scriptRegistry ownVerificationKey headId headParameters headUTxO sn sigs
531
517
where
532
- headScript = PlutusScriptSerialised Head. validatorScript
533
-
534
518
decommitValue = foldMap txOutValue $ fromMaybe mempty $ utxoToDecommit sn
535
519
536
520
isNegative = any ((< 0 ) . snd ) . IsList. toList
@@ -572,7 +556,7 @@ recover ctx headId depositedTxId spendableUTxO lowerValiditySlot = do
572
556
(_, depositedOut) <-
573
557
UTxO. findBy
574
558
( \ (TxIn txid _, txout) ->
575
- isScriptTxOut depositScript txout && txid == depositedTxId
559
+ isScriptTxOut depositValidatorScript txout && txid == depositedTxId
576
560
)
577
561
spendableUTxO
578
562
?> CannotFindDepositOutputToRecover {depositTxId = depositedTxId}
@@ -583,7 +567,6 @@ recover ctx headId depositedTxId spendableUTxO lowerValiditySlot = do
583
567
then Left InvalidHeadIdInRecover {headId}
584
568
else Right $ recoverTx depositedTxId deposited lowerValiditySlot
585
569
where
586
- depositScript = PlutusScriptSerialised depositValidatorScript
587
570
ChainContext {networkId} = ctx
588
571
589
572
-- | Construct a close transaction spending the head output in given 'UTxO',
@@ -612,7 +595,7 @@ close ::
612
595
close ctx spendableUTxO headId HeadParameters {parties, contestationPeriod} openVersion confirmedSnapshot startSlotNo pointInTime = do
613
596
pid <- headIdToPolicyId headId ?> InvalidHeadIdInClose {headId}
614
597
headUTxO <-
615
- UTxO. find (isScriptTxOut headScript ) (utxoOfThisHead pid spendableUTxO)
598
+ UTxO. find (isScriptTxOut Head. validatorScript ) (utxoOfThisHead pid spendableUTxO)
616
599
?> CannotFindHeadOutputToClose
617
600
let openThreadOutput =
618
601
OpenThreadOutput
@@ -626,8 +609,6 @@ close ctx spendableUTxO headId HeadParameters{parties, contestationPeriod} openV
626
609
where
627
610
Snapshot {utxoToCommit, utxoToDecommit} = getSnapshot confirmedSnapshot
628
611
629
- headScript = PlutusScriptSerialised Head. validatorScript
630
-
631
612
ChainContext {ownVerificationKey, scriptRegistry} = ctx
632
613
633
614
data ContestTxError
@@ -662,7 +643,7 @@ contest ::
662
643
contest ctx spendableUTxO headId contestationPeriod openVersion contestingSnapshot pointInTime = do
663
644
pid <- headIdToPolicyId headId ?> InvalidHeadIdInContest {headId}
664
645
headUTxO <-
665
- UTxO. find (isScriptTxOut headScript ) (utxoOfThisHead pid spendableUTxO)
646
+ UTxO. find (isScriptTxOut Head. validatorScript ) (utxoOfThisHead pid spendableUTxO)
666
647
?> CannotFindHeadOutputToContest
667
648
closedThreadOutput <- checkHeadDatum headUTxO
668
649
incrementalAction <- setIncrementalActionMaybe utxoToCommit utxoToDecommit ?> BothCommitAndDecommitInContest
@@ -698,8 +679,6 @@ contest ctx spendableUTxO headId contestationPeriod openVersion contestingSnapsh
698
679
699
680
ChainContext {ownVerificationKey, scriptRegistry} = ctx
700
681
701
- headScript = PlutusScriptSerialised Head. validatorScript
702
-
703
682
data FanoutTxError
704
683
= CannotFindHeadOutputToFanout
705
684
| MissingHeadDatumInFanout
@@ -727,7 +706,7 @@ fanout ::
727
706
Either FanoutTxError Tx
728
707
fanout ctx spendableUTxO seedTxIn utxo utxoToCommit utxoToDecommit deadlineSlotNo = do
729
708
headUTxO <-
730
- UTxO. find (isScriptTxOut headScript ) (utxoOfThisHead (headPolicyId seedTxIn) spendableUTxO)
709
+ UTxO. find (isScriptTxOut Head. validatorScript ) (utxoOfThisHead (headPolicyId seedTxIn) spendableUTxO)
731
710
?> CannotFindHeadOutputToFanout
732
711
closedThreadUTxO <- checkHeadDatum headUTxO
733
712
_ <- setIncrementalActionMaybe utxoToCommit utxoToDecommit ?> BothCommitAndDecommitInFanout
@@ -737,8 +716,6 @@ fanout ctx spendableUTxO seedTxIn utxo utxoToCommit utxoToDecommit deadlineSlotN
737
716
738
717
ChainContext {scriptRegistry} = ctx
739
718
740
- headScript = PlutusScriptSerialised Head. validatorScript
741
-
742
719
checkHeadDatum headUTxO@ (_, headOutput) = do
743
720
headDatum <-
744
721
txOutScriptData (toTxContext headOutput) ?> MissingHeadDatumInFanout
0 commit comments