Skip to content

Commit fc313cb

Browse files
committed
Rename to SubmitL2Tx
1 parent 6d41954 commit fc313cb

File tree

5 files changed

+26
-26
lines changed

5 files changed

+26
-26
lines changed
File renamed without changes.
File renamed without changes.

hydra-node/json-schemas/api.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ channels:
398398
servers:
399399
- localhost-http
400400
publish:
401-
operationId: submitHydraTxRequest
401+
operationId: submitL2TxRequest
402402
message:
403403
summary: |
404404
A transaction to be submitted to the head.
@@ -411,7 +411,7 @@ channels:
411411
method: POST
412412
bindingVersion: '0.1.0'
413413
subscribe:
414-
operationId: submitHydraTxResponse
414+
operationId: submitL2TxResponse
415415
message:
416416
oneOf:
417417
- name: SubmitTxConfirmed
@@ -3324,7 +3324,7 @@ components:
33243324
status:
33253325
$ref: "api.yaml#/components/schemas/DepositStatus"
33263326

3327-
SubmitHydraTxResponse:
3327+
SubmitL2TxResponse:
33283328
oneOf:
33293329
- title: SubmitTxConfirmed
33303330
type: object

hydra-node/src/Hydra/API/HTTPServer.hs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ instance (Arbitrary tx, Arbitrary (UTxOType tx), IsTx tx) => Arbitrary (SideLoad
126126
SideLoadSnapshotRequest snapshot -> SideLoadSnapshotRequest <$> shrink snapshot
127127

128128
-- | Request to submit a transaction to the head
129-
newtype SubmitHydraTxRequest tx = SubmitHydraTxRequest
130-
{ submitHydraTx :: tx
129+
newtype SubmitL2TxRequest tx = SubmitL2TxRequest
130+
{ submitL2Tx :: tx
131131
}
132132
deriving newtype (Eq, Show, Arbitrary)
133133
deriving newtype (ToJSON, FromJSON)
134134

135135
-- | Response for transaction submission
136-
data SubmitHydraTxResponse
136+
data SubmitL2TxResponse
137137
= -- | Transaction was included in a confirmed snapshot
138138
SubmitTxConfirmed Integer
139139
| -- | Transaction was rejected due to validation errors
@@ -142,7 +142,7 @@ data SubmitHydraTxResponse
142142
SubmitTxSubmitted
143143
deriving stock (Eq, Show, Generic)
144144

145-
instance ToJSON SubmitHydraTxResponse where
145+
instance ToJSON SubmitL2TxResponse where
146146
toJSON = \case
147147
SubmitTxConfirmed snapshotNumber ->
148148
object
@@ -156,7 +156,7 @@ instance ToJSON SubmitHydraTxResponse where
156156
]
157157
SubmitTxSubmitted -> object ["tag" .= Aeson.String "SubmitTxSubmitted"]
158158

159-
instance FromJSON SubmitHydraTxResponse where
159+
instance FromJSON SubmitL2TxResponse where
160160
parseJSON = withObject "SubmitTxResponse" $ \o -> do
161161
tag <- o .: "tag"
162162
case tag :: Text of
@@ -165,7 +165,7 @@ instance FromJSON SubmitHydraTxResponse where
165165
"SubmitTxSubmitted" -> pure SubmitTxSubmitted
166166
_ -> fail "Expected tag to be SubmitTxConfirmed, SubmitTxInvalid, or SubmitTxSubmitted"
167167

168-
instance Arbitrary SubmitHydraTxResponse where
168+
instance Arbitrary SubmitL2TxResponse where
169169
arbitrary = genericArbitrary
170170

171171
jsonContent :: ResponseHeaders
@@ -240,7 +240,7 @@ httpApp tracer directChain env pparams getHeadState getCommitInfo getPendingDepo
240240
>>= respond
241241
("POST", ["transaction"]) ->
242242
consumeRequestBodyStrict request
243-
>>= handleSubmitHydraTx putClientInput apiTransactionTimeout responseChannel
243+
>>= handleSubmitL2Tx putClientInput apiTransactionTimeout responseChannel
244244
>>= respond
245245
_ ->
246246
respond $ responseLBS status400 jsonContent . Aeson.encode $ Aeson.String "Resource not found"
@@ -373,27 +373,27 @@ handleSideLoadSnapshot putClientInput body = do
373373
putClientInput $ SideLoadSnapshot snapshot
374374
pure $ responseLBS status200 jsonContent (Aeson.encode $ Aeson.String "OK")
375375

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 ::
378378
forall tx.
379379
IsChainState tx =>
380380
(ClientInput tx -> IO ()) ->
381381
ApiTransactionTimeout ->
382382
TChan (Either (TimedServerOutput tx) (ClientMessage tx)) ->
383383
LBS.ByteString ->
384384
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
387387
Left err ->
388388
pure $ responseLBS status400 jsonContent (Aeson.encode $ Aeson.String $ pack err)
389-
Right SubmitHydraTxRequest{submitHydraTx} -> do
389+
Right SubmitL2TxRequest{submitL2Tx} -> do
390390
-- Duplicate the channel to avoid consuming messages from other consumers.
391391
dupChannel <- atomically $ dupTChan responseChannel
392392

393393
-- Submit the transaction to the head
394-
putClientInput (NewTx submitHydraTx)
394+
putClientInput (NewTx submitL2Tx)
395395

396-
let txid = txId submitHydraTx
396+
let txid = txId submitL2Tx
397397
result <-
398398
timeout
399399
(realToFrac (apiTransactionTimeoutNominalDiffTime apiTransactionTimeout))
@@ -420,7 +420,7 @@ handleSubmitHydraTx putClientInput apiTransactionTimeout responseChannel body =
420420
)
421421
where
422422
-- 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
424424
waitForTransactionResult dupChannel txid = go
425425
where
426426
go = do

hydra-node/test/Hydra/API/HTTPServerSpec.hs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import Hydra.API.HTTPServer (
1414
DraftCommitTxRequest (..),
1515
DraftCommitTxResponse (..),
1616
SideLoadSnapshotRequest (..),
17-
SubmitHydraTxRequest (..),
18-
SubmitHydraTxResponse (..),
17+
SubmitL2TxRequest (..),
18+
SubmitL2TxResponse (..),
1919
SubmitTxRequest (..),
2020
TransactionSubmitted,
2121
httpApp,
@@ -67,8 +67,8 @@ spec = do
6767
roundtripAndGoldenSpecs (Proxy @(ReasonablySized TransactionSubmitted))
6868
roundtripAndGoldenSpecs (Proxy @(ReasonablySized (SideLoadSnapshotRequest Tx)))
6969
roundtripAndGoldenSpecs (Proxy @(ReasonablySized (HeadState Tx)))
70-
roundtripAndGoldenSpecs (Proxy @(ReasonablySized SubmitHydraTxResponse))
71-
roundtripAndGoldenSpecs (Proxy @(ReasonablySized (SubmitHydraTxRequest Tx)))
70+
roundtripAndGoldenSpecs (Proxy @(ReasonablySized SubmitL2TxResponse))
71+
roundtripAndGoldenSpecs (Proxy @(ReasonablySized (SubmitL2TxRequest Tx)))
7272

7373
prop "Validate /commit publish api schema" $
7474
prop_validateJSONSchema @(DraftCommitTxRequest Tx) "api.json" $
@@ -175,18 +175,18 @@ spec = do
175175
. key "message"
176176

177177
prop "Validate /transaction publish api schema" $
178-
prop_validateJSONSchema @(SubmitHydraTxRequest Tx) "api.json" $
178+
prop_validateJSONSchema @(SubmitL2TxRequest Tx) "api.json" $
179179
key "channels"
180180
. key "/transaction"
181181
. key "publish"
182182
. key "message"
183183
. key "payload"
184184

185185
prop "Validate /transaction subscribe api schema" $
186-
prop_validateJSONSchema @SubmitHydraTxResponse "api.json" $
186+
prop_validateJSONSchema @SubmitL2TxResponse "api.json" $
187187
key "components"
188188
. key "schemas"
189-
. key "SubmitHydraTxResponse"
189+
. key "SubmitL2TxResponse"
190190

191191
apiServerSpec
192192
describe "SubmitTxRequest accepted tx formats" $ do
@@ -562,7 +562,7 @@ apiServerSpec = do
562562
_ -> 500
563563

564564
describe "POST /transaction" $ do
565-
let mkReq tx = encode $ SubmitHydraTxRequest tx
565+
let mkReq tx = encode $ SubmitL2TxRequest tx
566566
testTx = SimpleTx 42 mempty mempty
567567
testHeadId = generateWith arbitrary 42
568568
now <- runIO getCurrentTime

0 commit comments

Comments
 (0)