@@ -126,14 +126,14 @@ instance (Arbitrary tx, Arbitrary (UTxOType tx), IsTx tx) => Arbitrary (SideLoad
126
126
SideLoadSnapshotRequest snapshot -> SideLoadSnapshotRequest <$> shrink snapshot
127
127
128
128
-- | Request to submit a transaction to the head
129
- newtype SubmitHydraTxRequest tx = SubmitHydraTxRequest
130
- { submitHydraTx :: tx
129
+ newtype SubmitL2TxRequest tx = SubmitL2TxRequest
130
+ { submitL2Tx :: tx
131
131
}
132
132
deriving newtype (Eq , Show , Arbitrary )
133
133
deriving newtype (ToJSON , FromJSON )
134
134
135
135
-- | Response for transaction submission
136
- data SubmitHydraTxResponse
136
+ data SubmitL2TxResponse
137
137
= -- | Transaction was included in a confirmed snapshot
138
138
SubmitTxConfirmed Integer
139
139
| -- | Transaction was rejected due to validation errors
@@ -142,7 +142,7 @@ data SubmitHydraTxResponse
142
142
SubmitTxSubmitted
143
143
deriving stock (Eq , Show , Generic )
144
144
145
- instance ToJSON SubmitHydraTxResponse where
145
+ instance ToJSON SubmitL2TxResponse where
146
146
toJSON = \ case
147
147
SubmitTxConfirmed snapshotNumber ->
148
148
object
@@ -156,7 +156,7 @@ instance ToJSON SubmitHydraTxResponse where
156
156
]
157
157
SubmitTxSubmitted -> object [" tag" .= Aeson. String " SubmitTxSubmitted" ]
158
158
159
- instance FromJSON SubmitHydraTxResponse where
159
+ instance FromJSON SubmitL2TxResponse where
160
160
parseJSON = withObject " SubmitTxResponse" $ \ o -> do
161
161
tag <- o .: " tag"
162
162
case tag :: Text of
@@ -165,7 +165,7 @@ instance FromJSON SubmitHydraTxResponse where
165
165
" SubmitTxSubmitted" -> pure SubmitTxSubmitted
166
166
_ -> fail " Expected tag to be SubmitTxConfirmed, SubmitTxInvalid, or SubmitTxSubmitted"
167
167
168
- instance Arbitrary SubmitHydraTxResponse where
168
+ instance Arbitrary SubmitL2TxResponse where
169
169
arbitrary = genericArbitrary
170
170
171
171
jsonContent :: ResponseHeaders
@@ -240,7 +240,7 @@ httpApp tracer directChain env pparams getHeadState getCommitInfo getPendingDepo
240
240
>>= respond
241
241
(" POST" , [" transaction" ]) ->
242
242
consumeRequestBodyStrict request
243
- >>= handleSubmitHydraTx putClientInput apiTransactionTimeout responseChannel
243
+ >>= handleSubmitL2Tx putClientInput apiTransactionTimeout responseChannel
244
244
>>= respond
245
245
_ ->
246
246
respond $ responseLBS status400 jsonContent . Aeson. encode $ Aeson. String " Resource not found"
@@ -373,27 +373,27 @@ handleSideLoadSnapshot putClientInput body = do
373
373
putClientInput $ SideLoadSnapshot snapshot
374
374
pure $ responseLBS status200 jsonContent (Aeson. encode $ Aeson. String " OK" )
375
375
376
- -- | Handle request to submit a hydra transaction to the head.
377
- handleSubmitHydraTx ::
376
+ -- | Handle request to submit a transaction to the head.
377
+ handleSubmitL2Tx ::
378
378
forall tx .
379
379
IsChainState tx =>
380
380
(ClientInput tx -> IO () ) ->
381
381
ApiTransactionTimeout ->
382
382
TChan (Either (TimedServerOutput tx ) (ClientMessage tx )) ->
383
383
LBS. ByteString ->
384
384
IO Response
385
- handleSubmitHydraTx putClientInput apiTransactionTimeout responseChannel body = do
386
- case Aeson. eitherDecode' @ (SubmitHydraTxRequest tx ) body of
385
+ handleSubmitL2Tx putClientInput apiTransactionTimeout responseChannel body = do
386
+ case Aeson. eitherDecode' @ (SubmitL2TxRequest tx ) body of
387
387
Left err ->
388
388
pure $ responseLBS status400 jsonContent (Aeson. encode $ Aeson. String $ pack err)
389
- Right SubmitHydraTxRequest {submitHydraTx } -> do
389
+ Right SubmitL2TxRequest {submitL2Tx } -> do
390
390
-- Duplicate the channel to avoid consuming messages from other consumers.
391
391
dupChannel <- atomically $ dupTChan responseChannel
392
392
393
393
-- Submit the transaction to the head
394
- putClientInput (NewTx submitHydraTx )
394
+ putClientInput (NewTx submitL2Tx )
395
395
396
- let txid = txId submitHydraTx
396
+ let txid = txId submitL2Tx
397
397
result <-
398
398
timeout
399
399
(realToFrac (apiTransactionTimeoutNominalDiffTime apiTransactionTimeout))
@@ -420,7 +420,7 @@ handleSubmitHydraTx putClientInput apiTransactionTimeout responseChannel body =
420
420
)
421
421
where
422
422
-- Wait for transaction result by listening to events
423
- waitForTransactionResult :: TChan (Either (TimedServerOutput tx ) (ClientMessage tx )) -> TxIdType tx -> IO SubmitHydraTxResponse
423
+ waitForTransactionResult :: TChan (Either (TimedServerOutput tx ) (ClientMessage tx )) -> TxIdType tx -> IO SubmitL2TxResponse
424
424
waitForTransactionResult dupChannel txid = go
425
425
where
426
426
go = do
0 commit comments