@@ -13,7 +13,10 @@ import Data.Text (pack)
13
13
import Hydra.API.APIServerLog (APIServerLog (.. ), Method (.. ), PathInfo (.. ))
14
14
import Hydra.API.ClientInput (ClientInput (.. ))
15
15
import Hydra.API.ServerOutput (CommitInfo (.. ), getConfirmedSnapshot , getSeenSnapshot , getSnapshotUtxo )
16
- import Hydra.Cardano.Api (LedgerEra , Tx )
16
+ import Hydra.Cardano.Api (
17
+ LedgerEra ,
18
+ Tx ,
19
+ )
17
20
import Hydra.Chain (Chain (.. ), PostTxError (.. ), draftCommitTx )
18
21
import Hydra.Chain.ChainState (
19
22
IsChainState ,
@@ -236,29 +239,20 @@ handleDraftCommitUtxo env pparams directChain getCommitInfo body = do
236
239
SimpleCommitRequest {utxoToCommit} -> do
237
240
let blueprintTx = txSpendingUTxO utxoToCommit
238
241
draftCommit headId utxoToCommit blueprintTx
239
- IncrementalCommit headId ->
242
+ IncrementalCommit headId -> do
240
243
case someCommitRequest of
241
- FullCommitRequest {blueprintTx, utxo} ->
242
- checkDeposit' utxo $
243
- deposit headId CommitBlueprintTx {blueprintTx, lookupUTxO = utxo}
244
+ FullCommitRequest {blueprintTx, utxo} -> do
245
+ deposit headId CommitBlueprintTx {blueprintTx, lookupUTxO = utxo}
244
246
SimpleCommitRequest {utxoToCommit} ->
245
- checkDeposit' utxoToCommit $
246
- deposit headId CommitBlueprintTx {blueprintTx = txSpendingUTxO utxoToCommit, lookupUTxO = utxoToCommit}
247
+ deposit headId CommitBlueprintTx {blueprintTx = txSpendingUTxO utxoToCommit, lookupUTxO = utxoToCommit}
247
248
CannotCommit -> pure $ responseLBS status500 [] (Aeson. encode (FailedToDraftTxNotInitializing :: PostTxError tx ))
248
249
where
249
- checkDeposit' utxo cont = do
250
- depositCheck <- checkDeposit pparams utxo
251
- case depositCheck of
252
- Left e -> pure $ responseLBS status400 jsonContent (Aeson. encode $ toJSON e)
253
- Right _ -> cont
254
-
255
250
deposit headId commitBlueprint = do
256
251
-- NOTE: Three times deposit period means we have one deposit period time to
257
252
-- increment because a deposit only activates after one deposit period and
258
253
-- expires one deposit period before deadline.
259
- --
260
254
deadline <- addUTCTime (3 * toNominalDiffTime depositPeriod) <$> getCurrentTime
261
- draftDepositTx headId commitBlueprint deadline <&> \ case
255
+ draftDepositTx headId pparams commitBlueprint deadline <&> \ case
262
256
Left e -> responseLBS status400 jsonContent (Aeson. encode $ toJSON e)
263
257
Right depositTx -> okJSON $ DraftCommitTxResponse depositTx
264
258
@@ -271,12 +265,11 @@ handleDraftCommitUtxo env pparams directChain getCommitInfo body = do
271
265
CommittedTooMuchADAForMainnet _ _ -> badRequest e
272
266
UnsupportedLegacyOutput _ -> badRequest e
273
267
CannotFindOwnInitial _ -> badRequest e
274
- DepositTooLow _ _ -> badRequest e
275
268
_ -> responseLBS status500 [] (Aeson. encode $ toJSON e)
276
269
Right commitTx ->
277
270
okJSON $ DraftCommitTxResponse commitTx
278
271
279
- Chain {draftCommitTx, draftDepositTx, checkDeposit } = directChain
272
+ Chain {draftCommitTx, draftDepositTx} = directChain
280
273
281
274
Environment {depositPeriod} = env
282
275
0 commit comments