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