Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
project: cardano-api
pr: 1200
kind:
- compatible
description: |
Deprecate the old-API transaction body surface in favour of `Cardano.Api.Experimental`. The following are now annotated with `{-# DEPRECATED #-}`:

- `TxBody` (data type), `ShelleyTxBody` (constructor)
- `TxBodyContent` (type/constructor)
- `createTransactionBody`, `defaultTxBodyContent`
- `getTxBody`, `getTxBodyContent`
- `BalancedTxBody`

Internal modules that still consume these symbols are annotated with `-Wno-deprecations` so `-Werror` stays green; they will be migrated in a follow-up alongside the setter family. The pre-existing `TxBody` pattern-synonym deprecation message is updated for consistency.
8 changes: 8 additions & 0 deletions .changes/20260511_cardano_rpc_migrate_txid.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
project: cardano-rpc
pr: 1200
kind:
- refactoring
description: |
Migrate the UtxoRpc submit handler off the deprecated `getTxBody` /
`getTxId` chain. The transaction id is now computed directly from the
ledger transaction via `Cardano.Ledger.Core.txIdTx`.
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/Experimental/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

module Cardano.Api.Experimental.Tx
( -- * Creating transactions using the new API
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/Governance/Internal/Poll.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

-- | An API for driving on-chain poll for SPOs.
--
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/Network/IPC/Internal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# OPTIONS_GHC -Wno-deprecations #-}
-- The Shelley ledger uses promoted data kinds which we have to use, but we do
-- not export any from this API. We also use them unticked as nature intended.
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
Expand Down
8 changes: 7 additions & 1 deletion cardano-api/src/Cardano/Api/Tx/Internal/Body.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

module Cardano.Api.Tx.Internal.Body
( -- * Contents
Expand Down Expand Up @@ -861,6 +862,8 @@ indexWitnessedTxProposalProcedures (TxProposalProcedures proposals) = do
-- If you extend this type, consider updating:
-- - the 'makeShelleyTransactionBody' function of the relevant era below, and
-- - the @friendly*@ family of functions in cardano-cli.
{-# DEPRECATED TxBodyContent "Use 'TxBodyContent' from 'Cardano.Api.Experimental' instead." #-}

Comment on lines +865 to +866
data TxBodyContent build era
= TxBodyContent
{ txIns :: TxIns build era
Expand Down Expand Up @@ -890,6 +893,7 @@ data TxBodyContent build era
}
deriving (Eq, Show)

{-# DEPRECATED defaultTxBodyContent "Use 'TxBodyContent' from 'Cardano.Api.Experimental' instead." #-}
defaultTxBodyContent
Comment on lines +896 to 897
:: ()
=> ShelleyBasedEra era
Expand Down Expand Up @@ -1252,6 +1256,7 @@ instance Error TxBodyError where
<> "in input "
<> pretty txin

{-# DEPRECATED createTransactionBody "Use 'makeUnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
createTransactionBody
:: forall era
. HasCallStack
Expand Down Expand Up @@ -1434,12 +1439,13 @@ txBodyContentHasTxIns txIns = guard (not (null txIns)) ?! TxBodyEmptyTxIns
maxShelleyTxInIx :: Word
maxShelleyTxInIx = fromIntegral $ maxBound @Word16

{-# DEPRECATED TxBody "Use getTxBodyContent $ getTxBody instead" #-}
{-# DEPRECATED TxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
pattern TxBody :: TxBodyContent ViewTx era -> TxBody era
pattern TxBody txbodycontent <- (getTxBodyContent -> txbodycontent)

{-# COMPLETE TxBody #-}

{-# DEPRECATED getTxBodyContent "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
getTxBodyContent :: TxBody era -> TxBodyContent ViewTx era
getTxBodyContent = \case
ShelleyTxBody sbe body _scripts scriptdata mAux scriptValidity ->
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/Tx/Internal/Convenience.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE DataKinds #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

-- | Convenience transaction construction functions
module Cardano.Api.Tx.Internal.Convenience
Expand Down
3 changes: 3 additions & 0 deletions cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

-- | Calculating fees.
module Cardano.Api.Tx.Internal.Fee
Expand Down Expand Up @@ -960,6 +961,8 @@ handleExUnitsErrors ScriptInvalid failuresMap exUnitsMap
| null failuresMap = Left TxBodyScriptBadScriptValidity
| otherwise = Right $ Map.map (\_ -> ExecutionUnits 0 0) failuresMap <> exUnitsMap

{-# DEPRECATED BalancedTxBody "Use 'Cardano.Api.Experimental' transaction balancing instead." #-}

data BalancedTxBody era
= BalancedTxBody
(TxBodyContent BuildTx era)
Expand Down
6 changes: 6 additions & 0 deletions cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ViewPatterns #-}
{-# OPTIONS_GHC -Wno-deprecations #-}
-- The Shelley ledger uses promoted data kinds which we have to use, but we do
-- not export any from this API. We also use them unticked as nature intended.
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
Expand Down Expand Up @@ -246,6 +247,7 @@ deserialiseShelleyBasedTx mkTx bs =
-- NB: This is called in getTxBodyAndWitnesses which is fine as
-- getTxBodyAndWitnesses is only called in the context of a
-- shelley based era anyways. ByronTx will eventually be removed.
{-# DEPRECATED getTxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
getTxBody :: Tx era -> TxBody era
getTxBody (ShelleyTx sbe tx) =
caseShelleyToMaryOrAlonzoEraOnwards
Expand Down Expand Up @@ -294,6 +296,10 @@ instance IsShelleyBasedEra era => HasTextEnvelope (Tx era) where
--
-- TODO: We can use Ledger.Tx era here however we would need to rename TxBody
-- as technically it is not strictly a transaction body.
{-# DEPRECATED TxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}

{-# DEPRECATED ShelleyTxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}

data TxBody era where
ShelleyTxBody
:: ShelleyBasedEra era
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

module Test.Cardano.Api.Experimental
( tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

module Test.Cardano.Api.Transaction.Autobalance
( tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
{-# OPTIONS_GHC -Wno-deprecations #-}

module Test.Cardano.Api.TxBody
( tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import Cardano.Rpc.Server.Internal.Monad
import Cardano.Rpc.Server.Internal.Orphans ()
import Cardano.Rpc.Server.Internal.Tracing

import Cardano.Ledger.Core qualified as L

import RIO hiding (toList)

import Data.Default
Expand Down Expand Up @@ -61,7 +63,9 @@ submitTxMethod req = do
submitTxToNodeLocal nodeConnInfo (TxInMode sbe tx) <&> \case
TxSubmitError e -> Left $ TraceRpcSubmitN2cConnectionError e
TxSubmitFail reason -> Left $ TraceRpcSubmitTxValidationError reason
TxSubmitSuccess -> Right $ getTxId $ getTxBody tx
TxSubmitSuccess ->
let ShelleyTx _ ledgerTx = tx
in Right $ shelleyBasedEraConstraints sbe $ fromShelleyTxId (L.txIdTx ledgerTx)
putTraceThrowEither result

putTraceThrowEither v = withFrozenCallStack $ do
Expand Down
Loading