@@ -14,7 +14,7 @@ import HydraAuctionOnchain.Types.StandingBidState (PStandingBidState, pvalidateN
14
14
import Plutarch.Api.V1.Value (pvalueOf )
15
15
import Plutarch.Api.V2 (PCurrencySymbol , PScriptContext , PTxInInfo , PTxInfo , PTxOut )
16
16
import Plutarch.Extra.Interval (pcontains )
17
- import Plutarch.Extra.ScriptContext (ptryOwnInput )
17
+ import Plutarch.Extra.ScriptContext (ptryOwnInput , ptxSignedBy )
18
18
import Plutarch.Monadic qualified as P
19
19
20
20
--------------------------------------------------------------------------------
@@ -52,6 +52,7 @@ instance ToErrorCode PStandingBidError where
52
52
StandingBid'Error'UnexpectedTokensMintedBurned ->
53
53
pconstant " StandingBid02"
54
54
55
+ -- NewBid ----------------------------------------------------------------------
55
56
data PStandingBid'NewBid'Error (s :: S )
56
57
= StandingBid'NewBid'Error'MissingOwnOutput
57
58
| StandingBid'NewBid'Error'OwnOutputMissingToken
@@ -78,6 +79,24 @@ instance ToErrorCode PStandingBid'NewBid'Error where
78
79
StandingBid'NewBid'Error'IncorrectValidityInterval ->
79
80
pconstant " StandingBid_NewBid_05"
80
81
82
+ -- MoveToHydra -----------------------------------------------------------------
83
+ data PStandingBid'MoveToHydra'Error (s :: S )
84
+ = StandingBid'MoveToHydra'Error'MissingDelegateSignatures
85
+ | StandingBid'MoveToHydra'Error'IncorrectValidityInterval
86
+ deriving stock (Generic )
87
+ deriving anyclass (PlutusType )
88
+
89
+ instance DerivePlutusType PStandingBid'MoveToHydra'Error where
90
+ type DPTStrat _ = PlutusTypeScott
91
+
92
+ instance ToErrorCode PStandingBid'MoveToHydra'Error where
93
+ toErrorCode = phoistAcyclic $
94
+ plam $ \ err -> pmatch err $ \ case
95
+ StandingBid'MoveToHydra'Error'MissingDelegateSignatures ->
96
+ pconstant " StandingBid_MoveToHydra_01"
97
+ StandingBid'MoveToHydra'Error'IncorrectValidityInterval ->
98
+ pconstant " StandingBid_MoveToHydra_02"
99
+
81
100
--------------------------------------------------------------------------------
82
101
-- Validator
83
102
--------------------------------------------------------------------------------
@@ -112,7 +131,7 @@ standingBidValidator = phoistAcyclic $
112
131
NewBidRedeemer _ ->
113
132
pcheckNewBid # txInfo # auctionCs # auctionTerms # ownInput # oldBidState
114
133
MoveToHydraRedeemer _ ->
115
- pcheckMoveToHydra
134
+ pcheckMoveToHydra # txInfo # auctionTerms
116
135
ConcludeAuctionRedeemer _ ->
117
136
pcheckConcludeAuction
118
137
@@ -172,8 +191,23 @@ pcheckNewBid = phoistAcyclic $
172
191
-- MoveToHydra
173
192
--------------------------------------------------------------------------------
174
193
175
- pcheckMoveToHydra :: Term s PUnit
176
- pcheckMoveToHydra = undefined
194
+ pcheckMoveToHydra :: Term s (PTxInfo :--> PAuctionTerms :--> PUnit )
195
+ pcheckMoveToHydra = phoistAcyclic $
196
+ plam $ \ txInfo auctionTerms -> P. do
197
+ txInfoFields <- pletFields @ [" signatories" , " validRange" ] txInfo
198
+
199
+ -- (StandingBid_MoveToHydra_01)
200
+ -- The transaction should be signed by all the delegates.
201
+ delegates <- plet $ pfield @ " delegates" # auctionTerms
202
+ err StandingBid'MoveToHydra'Error'MissingDelegateSignatures $
203
+ pall # plam (\ sig -> ptxSignedBy # txInfoFields. signatories # sig) # delegates
204
+
205
+ -- (StandingBid_MoveToHydra_02)
206
+ -- The transaction validity should end before the bidding end time.
207
+ err StandingBid'MoveToHydra'Error'IncorrectValidityInterval $
208
+ pcontains # (pbiddingPeriod # auctionTerms) # txInfoFields. validRange
209
+
210
+ pcon PUnit
177
211
178
212
--------------------------------------------------------------------------------
179
213
-- ConcludeAuction
0 commit comments