@@ -33,6 +33,7 @@ import HydraAuctionOnchain.Types.AuctionEscrowState
33
33
import HydraAuctionOnchain.Types.AuctionTerms
34
34
( PAuctionTerms
35
35
, pbiddingPeriod
36
+ , ppenaltyPeriod
36
37
, ppurchasePeriod
37
38
, ptotalAuctionFees
38
39
)
@@ -127,7 +128,13 @@ auctionEscrowValidator = phoistAcyclic $
127
128
# oldAuctionState
128
129
# ownAddress
129
130
SellerReclaimsRedeemer _ ->
130
- undefined
131
+ pcheckSellerReclaims
132
+ # feeEscrowSh
133
+ # txInfo
134
+ # auctionCs
135
+ # auctionTerms
136
+ # oldAuctionState
137
+ # ownAddress
131
138
CleanupAuctionRedeemer _ ->
132
139
undefined
133
140
@@ -332,9 +339,7 @@ pcheckBidderBuys = phoistAcyclic $
332
339
passert $ (errCode AuctionEscrow'BidderBuys'Error'AuctionLotNotPaidToBidder ) $
333
340
auctionTermsFields. auctionLot #<= pvaluePaidTo # txInfo # bidderPkh
334
341
335
- -- (AUES26) The bidder deposit's bidder consents to the
336
- -- transcation either explictly by signing the transaction or
337
- -- implicitly by receiving the bid deposit ADA.
342
+ -- (AUES26) The bidder signed the transaction.
338
343
passert $ (errCode AuctionEscrow'BidderBuys'Error'NoBidderConsent ) $
339
344
ptxSignedBy # txInfoFields. signatories # pdata bidderPkh
340
345
@@ -358,3 +363,96 @@ pcheckBidderBuys = phoistAcyclic $
358
363
#<= (plovelaceValueOf #$ pvaluePaidToScript # txInfo # feeEscrowSh)
359
364
360
365
pcon PUnit
366
+
367
+ --------------------------------------------------------------------------------
368
+ -- SellerReclaims
369
+ --------------------------------------------------------------------------------
370
+
371
+ pcheckSellerReclaims
372
+ :: Term
373
+ s
374
+ ( PScriptHash
375
+ :--> PTxInfo
376
+ :--> PCurrencySymbol
377
+ :--> PAuctionTerms
378
+ :--> PAuctionEscrowState
379
+ :--> PAddress
380
+ :--> PUnit
381
+ )
382
+ pcheckSellerReclaims = phoistAcyclic $
383
+ plam $ \ feeEscrowSh txInfo auctionCs auctionTerms oldAuctionState ownAddress -> P. do
384
+ txInfoFields <- pletFields @ [" mint" , " signatories" , " validRange" ] txInfo
385
+ auctionTermsFields <- pletFields @ [" auctionLot" , " sellerPkh" ] auctionTerms
386
+ let sellerPkh = auctionTermsFields. sellerPkh
387
+
388
+ -- (AUES29) There should be no tokens minted or burned.
389
+ passert $ (errCode AuctionEscrow'SellerReclaims'Error'UnexpectedTokensMintedBurned ) $
390
+ pfromData txInfoFields. mint #== mempty
391
+
392
+ -- (AUES30) This redeemer can only be used during
393
+ -- the penalty period.
394
+ passert $ (errCode AuctionEscrow'SellerReclaims'Error'IncorrectValidityInterval ) $
395
+ pcontains # (ppenaltyPeriod # auctionTerms) # txInfoFields. validRange
396
+
397
+ ----------------------------------------------------------------------------
398
+ -- Check auction escrow state transition
399
+ ----------------------------------------------------------------------------
400
+
401
+ -- (AUES31) There should be exactly one auction escrow output.
402
+ ownOutput <-
403
+ plet $
404
+ passertMaybe
405
+ $ (errCode AuctionEscrow'SellerReclaims'Error'MissingAuctionEscrowOutput )
406
+ (pfindUniqueOutputWithAddress # ownAddress # txInfo)
407
+
408
+ -- (AUES32) The auction escrow output should contain
409
+ -- the auction escrow token.
410
+ passert
411
+ $ (errCode AuctionEscrow'SellerReclaims'Error'AuctionEscrowOutputMissingAuctionEscrowToken )
412
+ (ptxOutContainsAuctionEscrowToken # auctionCs # ownOutput)
413
+
414
+ -- (AUES33) The auction escrow output should contain
415
+ -- the standing bid token.
416
+ passert
417
+ $ (errCode AuctionEscrow'SellerReclaims'Error'AuctionEscrowOutputMissingStandingBidToken )
418
+ (ptxOutContainsStandingBidToken # auctionCs # ownOutput)
419
+
420
+ -- (AUES34) The auction escrow output's datum should be decodable
421
+ -- as an auction escrow state.
422
+ newAuctionState <-
423
+ plet $
424
+ passertMaybe
425
+ $ (errCode AuctionEscrow'SellerReclaims'Error'FailedToDecodeAuctionEscrowState )
426
+ (pdecodeInlineDatum # ownOutput)
427
+
428
+ -- (AUES35) The auction state should transition from
429
+ -- `BiddingStarted` to `AuctionConcluded`.
430
+ passert $ (errCode AuctionEscrow'SellerReclaims'Error'InvalidAuctionStateTransition ) $
431
+ pvalidateAuctionEscrowTransitionToAuctionConcluded
432
+ # oldAuctionState
433
+ # newAuctionState
434
+
435
+ ----------------------------------------------------------------------------
436
+ -- Check auction lot transfer back to the seller
437
+ ----------------------------------------------------------------------------
438
+
439
+ -- (AUES36) The auction lot is returned to the seller.
440
+ passert $ (errCode AuctionEscrow'SellerReclaims'Error'PaymentToSellerIncorrect ) $
441
+ auctionTermsFields. auctionLot
442
+ #<= (pvaluePaidTo # txInfo # sellerPkh)
443
+
444
+ -- (AUES37) The seller signed the transaction.
445
+ passert $ (errCode AuctionEscrow'SellerReclaims'Error'NoSellerConsent ) $
446
+ ptxSignedBy # txInfoFields. signatories # pdata sellerPkh
447
+
448
+ ----------------------------------------------------------------------------
449
+ -- Check auction fees
450
+ ----------------------------------------------------------------------------
451
+
452
+ -- (AUES38) The total auction fees are sent to
453
+ -- the fee escrow validator.
454
+ passert $ (errCode AuctionEscrow'SellerReclaims'Error'PaymentToFeeEscrowIncorrect ) $
455
+ (ptotalAuctionFees # auctionTerms)
456
+ #<= (plovelaceValueOf #$ pvaluePaidToScript # txInfo # feeEscrowSh)
457
+
458
+ pcon PUnit
0 commit comments