Skip to content

Commit 1272b84

Browse files
authored
Merge pull request #1200 from IntersectMBO/jordan/deprecate-txbody-txbodycontent
Deprecate TxBody and TxBodyContent in favour of the experimental API
2 parents aabb5d1 + bc1b34c commit 1272b84

13 files changed

Lines changed: 50 additions & 2 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
project: cardano-api
2+
pr: 1200
3+
kind:
4+
- compatible
5+
description: |
6+
Deprecate the old-API transaction body surface in favour of `Cardano.Api.Experimental`. The following are now annotated with `{-# DEPRECATED #-}`:
7+
8+
- `TxBody` (data type), `ShelleyTxBody` (constructor)
9+
- `TxBodyContent` (type/constructor)
10+
- `createTransactionBody`, `defaultTxBodyContent`
11+
- `getTxBody`, `getTxBodyContent`
12+
- `BalancedTxBody`
13+
14+
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.
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-api/src/Cardano/Api/Experimental/Tx.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{-# LANGUAGE TypeApplications #-}
1111
{-# LANGUAGE TypeFamilies #-}
1212
{-# LANGUAGE UndecidableInstances #-}
13+
{-# OPTIONS_GHC -Wno-deprecations #-}
1314

1415
module Cardano.Api.Experimental.Tx
1516
( -- * Creating transactions using the new API

cardano-api/src/Cardano/Api/Governance/Internal/Poll.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{-# LANGUAGE ScopedTypeVariables #-}
88
{-# LANGUAGE TypeApplications #-}
99
{-# LANGUAGE TypeFamilies #-}
10+
{-# OPTIONS_GHC -Wno-deprecations #-}
1011

1112
-- | An API for driving on-chain poll for SPOs.
1213
--

cardano-api/src/Cardano/Api/Network/IPC/Internal.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
{-# LANGUAGE ScopedTypeVariables #-}
88
{-# LANGUAGE TypeFamilies #-}
99
{-# LANGUAGE TypeOperators #-}
10+
{-# OPTIONS_GHC -Wno-deprecations #-}
1011
-- The Shelley ledger uses promoted data kinds which we have to use, but we do
1112
-- not export any from this API. We also use them unticked as nature intended.
1213
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}

cardano-api/src/Cardano/Api/Tx/Internal/Body.hs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
{-# LANGUAGE TypeFamilies #-}
1616
{-# LANGUAGE TypeOperators #-}
1717
{-# LANGUAGE ViewPatterns #-}
18+
{-# OPTIONS_GHC -Wno-deprecations #-}
1819

1920
module Cardano.Api.Tx.Internal.Body
2021
( -- * Contents
@@ -861,6 +862,8 @@ indexWitnessedTxProposalProcedures (TxProposalProcedures proposals) = do
861862
-- If you extend this type, consider updating:
862863
-- - the 'makeShelleyTransactionBody' function of the relevant era below, and
863864
-- - the @friendly*@ family of functions in cardano-cli.
865+
{-# DEPRECATED TxBodyContent "Use 'TxBodyContent' from 'Cardano.Api.Experimental.Tx' instead." #-}
866+
864867
data TxBodyContent build era
865868
= TxBodyContent
866869
{ txIns :: TxIns build era
@@ -890,6 +893,7 @@ data TxBodyContent build era
890893
}
891894
deriving (Eq, Show)
892895

896+
{-# DEPRECATED defaultTxBodyContent "Use 'defaultTxBodyContent' from 'Cardano.Api.Experimental.Tx' instead." #-}
893897
defaultTxBodyContent
894898
:: ()
895899
=> ShelleyBasedEra era
@@ -1252,6 +1256,7 @@ instance Error TxBodyError where
12521256
<> "in input "
12531257
<> pretty txin
12541258

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

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

14411446
{-# COMPLETE TxBody #-}
14421447

1448+
{-# DEPRECATED getTxBodyContent "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
14431449
getTxBodyContent :: TxBody era -> TxBodyContent ViewTx era
14441450
getTxBodyContent = \case
14451451
ShelleyTxBody sbe body _scripts scriptdata mAux scriptValidity ->

cardano-api/src/Cardano/Api/Tx/Internal/Convenience.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{-# LANGUAGE DataKinds #-}
2+
{-# OPTIONS_GHC -Wno-deprecations #-}
23

34
-- | Convenience transaction construction functions
45
module Cardano.Api.Tx.Internal.Convenience

cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
{-# LANGUAGE ScopedTypeVariables #-}
1111
{-# LANGUAGE StandaloneDeriving #-}
1212
{-# LANGUAGE TupleSections #-}
13+
{-# OPTIONS_GHC -Wno-deprecations #-}
1314

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

964+
{-# DEPRECATED BalancedTxBody "Use 'Cardano.Api.Experimental' transaction balancing instead." #-}
965+
963966
data BalancedTxBody era
964967
= BalancedTxBody
965968
(TxBodyContent BuildTx era)

cardano-api/src/Cardano/Api/Tx/Internal/Sign.hs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
{-# LANGUAGE TypeFamilies #-}
1010
{-# LANGUAGE TypeOperators #-}
1111
{-# LANGUAGE ViewPatterns #-}
12+
{-# OPTIONS_GHC -Wno-deprecations #-}
1213
-- The Shelley ledger uses promoted data kinds which we have to use, but we do
1314
-- not export any from this API. We also use them unticked as nature intended.
1415
{-# OPTIONS_GHC -Wno-unticked-promoted-constructors #-}
@@ -246,6 +247,7 @@ deserialiseShelleyBasedTx mkTx bs =
246247
-- NB: This is called in getTxBodyAndWitnesses which is fine as
247248
-- getTxBodyAndWitnesses is only called in the context of a
248249
-- shelley based era anyways. ByronTx will eventually be removed.
250+
{-# DEPRECATED getTxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
249251
getTxBody :: Tx era -> TxBody era
250252
getTxBody (ShelleyTx sbe tx) =
251253
caseShelleyToMaryOrAlonzoEraOnwards
@@ -294,6 +296,10 @@ instance IsShelleyBasedEra era => HasTextEnvelope (Tx era) where
294296
--
295297
-- TODO: We can use Ledger.Tx era here however we would need to rename TxBody
296298
-- as technically it is not strictly a transaction body.
299+
{-# DEPRECATED TxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
300+
301+
{-# DEPRECATED ShelleyTxBody "Use 'UnsignedTx' from 'Cardano.Api.Experimental' instead." #-}
302+
297303
data TxBody era where
298304
ShelleyTxBody
299305
:: ShelleyBasedEra era

cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
{-# LANGUAGE ScopedTypeVariables #-}
66
{-# LANGUAGE TypeApplications #-}
77
{-# LANGUAGE TypeFamilies #-}
8+
{-# OPTIONS_GHC -Wno-deprecations #-}
89

910
module Test.Cardano.Api.Experimental
1011
( tests

0 commit comments

Comments
 (0)