@@ -9,6 +9,7 @@ import HydraAuctionOnchain.Helpers
9
9
( pdecodeInlineDatum
10
10
, pfindUniqueInputWithToken
11
11
, pfindUniqueOutputWithAddress
12
+ , pgetOwnInput
12
13
, putxoAddress
13
14
)
14
15
import HydraAuctionOnchain.MintingPolicies.Auction
@@ -30,7 +31,7 @@ import Plutarch.Api.V2
30
31
)
31
32
import Plutarch.Extra.Interval (pcontains )
32
33
import Plutarch.Extra.Maybe (pmaybe )
33
- import Plutarch.Extra.ScriptContext (ptryFromRedeemer , ptryOwnInput , ptxSignedBy )
34
+ import Plutarch.Extra.ScriptContext (ptryFromRedeemer , ptxSignedBy )
34
35
import Plutarch.Monadic qualified as P
35
36
36
37
--------------------------------------------------------------------------------
@@ -63,15 +64,21 @@ standingBidValidator
63
64
)
64
65
standingBidValidator = phoistAcyclic $
65
66
plam $ \ auctionCs auctionTerms oldBidState redeemer ctx -> P. do
66
- ownInput <- plet $ ptryOwnInput # ctx
67
+ -- (STBD0) The validator's own input should exist.
68
+ ownInput <-
69
+ plet $
70
+ passertMaybe
71
+ $ (errCode StandingBid'Error'MissingStandingBidInput )
72
+ (pgetOwnInput # ctx)
73
+
67
74
txInfo <- plet $ pfield @ " txInfo" # ctx
68
75
69
- -- (STBD0 ) The standing bid input should contain the standing
76
+ -- (STBD1 ) The standing bid input should contain the standing
70
77
-- bid token.
71
78
passert $ (errCode StandingBid'Error'OwnInputMissingToken ) $
72
79
ptxOutContainsStandingBidToken # auctionCs #$ pfield @ " resolved" # ownInput
73
80
74
- -- (STBD1 ) There should be no tokens minted or burned.
81
+ -- (STBD2 ) There should be no tokens minted or burned.
75
82
mintValue <- plet $ pfield @ " mint" # txInfo
76
83
passert $ (errCode StandingBid'Error'UnexpectedTokensMintedBurned ) $
77
84
pfromData mintValue #== mempty
@@ -100,32 +107,32 @@ pcheckNewBid
100
107
)
101
108
pcheckNewBid = phoistAcyclic $
102
109
plam $ \ txInfo auctionCs auctionTerms ownInput oldBidState -> P. do
103
- -- (STBD2 ) The standing bid output should exist.
110
+ -- (STBD3 ) The standing bid output should exist.
104
111
ownOutput <-
105
112
plet $
106
113
passertMaybe
107
114
$ (errCode StandingBid'NewBid'Error'MissingOwnOutput )
108
115
(pfindUniqueOutputWithAddress # (putxoAddress # ownInput) # txInfo)
109
116
110
- -- (STBD3 ) The standing bid output should contain the standing
117
+ -- (STBD4 ) The standing bid output should contain the standing
111
118
-- bid token.
112
119
passert $ (errCode StandingBid'NewBid'Error'OwnOutputMissingToken ) $
113
120
ptxOutContainsStandingBidToken # auctionCs # ownOutput
114
121
115
- -- (STBD4 ) The standing bid output's datum should be decodable
122
+ -- (STBD5 ) The standing bid output's datum should be decodable
116
123
-- as a standing bid state.
117
124
newBidState <-
118
125
plet $
119
126
passertMaybe
120
127
$ (errCode StandingBid'NewBid'Error'FailedToDecodeNewBid )
121
128
(pdecodeInlineDatum # ownOutput)
122
129
123
- -- (STBD5 ) The transition from the old bid state to the new
130
+ -- (STBD6 ) The transition from the old bid state to the new
124
131
-- bid state should be valid.
125
132
passert $ (errCode StandingBid'NewBid'Error'InvalidNewBidState ) $
126
133
pvalidateNewBid # auctionCs # auctionTerms # oldBidState # newBidState
127
134
128
- -- (STBD6 ) The transaction validity should end before the
135
+ -- (STBD7 ) The transaction validity should end before the
129
136
-- bidding end time.
130
137
txInfoValidRange <- plet $ pfield @ " validRange" # txInfo
131
138
passert $ (errCode StandingBid'NewBid'Error'IncorrectValidityInterval ) $
@@ -142,12 +149,12 @@ pcheckMoveToHydra = phoistAcyclic $
142
149
plam $ \ txInfo auctionTerms -> P. do
143
150
txInfoFields <- pletFields @ [" signatories" , " validRange" ] txInfo
144
151
145
- -- (STBD7 ) The transaction should be signed by all the delegates.
152
+ -- (STBD8 ) The transaction should be signed by all the delegates.
146
153
delegates <- plet $ pfield @ " delegates" # auctionTerms
147
154
passert $ (errCode StandingBid'MoveToHydra'Error'MissingDelegateSignatures ) $
148
155
pall # plam (\ sig -> ptxSignedBy # txInfoFields. signatories # sig) # delegates
149
156
150
- -- (STBD8 ) The transaction validity should end before the
157
+ -- (STBD9 ) The transaction validity should end before the
151
158
-- bidding end time.
152
159
passert $ (errCode StandingBid'MoveToHydra'Error'IncorrectValidityInterval ) $
153
160
pcontains # (pbiddingPeriod # auctionTerms) # txInfoFields. validRange
@@ -161,15 +168,15 @@ pcheckMoveToHydra = phoistAcyclic $
161
168
pcheckConcludeAuction :: Term s (PTxInfo :--> PCurrencySymbol :--> PUnit )
162
169
pcheckConcludeAuction = phoistAcyclic $
163
170
plam $ \ txInfo auctionCs -> P. do
164
- -- (STBD9 ) There is an input that contains
171
+ -- (STBD10 ) There is an input that contains
165
172
-- the auction escrow token.
166
173
auctionEscrowUtxo <-
167
174
plet $
168
175
passertMaybe
169
176
$ (errCode StandingBid'ConcludeAuction'Error'MissingAuctionEscrowInput )
170
177
(pfindUniqueInputWithToken # auctionCs # auctionEscrowTokenName # txInfo)
171
178
172
- -- (STBD10 ) The auction escrow input is being spent with the
179
+ -- (STBD11 ) The auction escrow input is being spent with the
173
180
-- `BidderBuys` or `SellerReclaims` redeemer. Implicitly, this
174
181
-- means that the auction is concluding with either the winning
175
182
-- bidder buying the auction lot or the seller reclaiming it.
0 commit comments