Skip to content

Commit 3b808dd

Browse files
committed
Migrate cardano-rpc submit handler to Ledger.txIdTx
Replace the deprecated getTxBody/getTxId chain in Cardano.Rpc.Server.Internal.UtxoRpc.Submit with a direct ledger projection: pattern-match the API Tx, then compute the TxId via Cardano.Ledger.Core.txIdTx (which is bodyTxL composed with txIdTxBody) and lift back through fromShelleyTxId.
1 parent 67ad5f7 commit 3b808dd

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
project: cardano-rpc
2+
pr: 1200
3+
kind:
4+
- refactoring
5+
description: |
6+
Migrate the UtxoRpc submit handler off the deprecated `getTxBody` /
7+
`getTxId` chain. The transaction id is now computed directly from the
8+
ledger transaction via `Cardano.Ledger.Core.txIdTx`.

cardano-rpc/src/Cardano/Rpc/Server/Internal/UtxoRpc/Submit.hs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import Cardano.Rpc.Server.Internal.Monad
2121
import Cardano.Rpc.Server.Internal.Orphans ()
2222
import Cardano.Rpc.Server.Internal.Tracing
2323

24+
import Cardano.Ledger.Core qualified as L
25+
2426
import RIO hiding (toList)
2527

2628
import Data.Default
@@ -61,7 +63,9 @@ submitTxMethod req = do
6163
submitTxToNodeLocal nodeConnInfo (TxInMode sbe tx) <&> \case
6264
TxSubmitError e -> Left $ TraceRpcSubmitN2cConnectionError e
6365
TxSubmitFail reason -> Left $ TraceRpcSubmitTxValidationError reason
64-
TxSubmitSuccess -> Right $ getTxId $ getTxBody tx
66+
TxSubmitSuccess ->
67+
let ShelleyTx _ ledgerTx = tx
68+
in Right $ shelleyBasedEraConstraints sbe $ fromShelleyTxId (L.txIdTx ledgerTx)
6569
putTraceThrowEither result
6670

6771
putTraceThrowEither v = withFrozenCallStack $ do

0 commit comments

Comments
 (0)