From bafd1c31d63f0fefa109a17783957dd0102b082a Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 22 Jul 2026 11:14:33 -0400 Subject: [PATCH 1/4] Re-export ledger accessors auxDataTxL and metadataTxAuxDataL Widen the EraTx re-export to include auxDataTxL, and re-export EraTxAuxData(metadataTxAuxDataL) from Cardano.Api.Ledger. Together these let downstream code read a transaction's auxiliary data (metadata) through the ledger lenses without depending on cardano-ledger directly. --- cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index 2b6ce58c43..12c180f3fe 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -163,7 +163,8 @@ module Cardano.Api.Ledger.Internal.Reexport , pattern AlonzoGenesis , AsIxItem (..) , EraGov - , EraTx (witsTxL, bodyTxL) + , EraTx (witsTxL, bodyTxL, auxDataTxL) + , EraTxAuxData (metadataTxAuxDataL) , EraTxBody (..) , TopTx , Tx @@ -228,7 +229,7 @@ import Cardano.Ledger.Alonzo.Core , AsIxItem (AsIxItem) , CoinPerWord (..) , EraGov - , EraTx (bodyTxL, witsTxL) + , EraTx (bodyTxL, witsTxL, auxDataTxL) , EraTxWits (..) , PParamsUpdate (..) , Tx @@ -347,6 +348,7 @@ import Cardano.Ledger.Conway.TxCert import Cardano.Ledger.Core ( Era (..) , EraPParams (..) + , EraTxAuxData (metadataTxAuxDataL) , EraTxBody (..) , EraTxOut , PParams (..) From 4392c3d8c140008170bc9742d47bbe8827b8e4ed Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 22 Jul 2026 11:15:58 -0400 Subject: [PATCH 2/4] Add changelog fragment for auxDataTxL/metadataTxAuxDataL re-export --- .changes/reexport-txauxdata-accessors.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changes/reexport-txauxdata-accessors.yml diff --git a/.changes/reexport-txauxdata-accessors.yml b/.changes/reexport-txauxdata-accessors.yml new file mode 100644 index 0000000000..bcfb2426ee --- /dev/null +++ b/.changes/reexport-txauxdata-accessors.yml @@ -0,0 +1,6 @@ +project: cardano-api +pr: 1262 +kind: + - compatible +description: | + Re-export the ledger accessors `auxDataTxL` (via `EraTx`) and `metadataTxAuxDataL` (via `EraTxAuxData`) from `Cardano.Api.Ledger`, so downstream code can read a transaction's auxiliary data (metadata) through the ledger lenses without depending on `cardano-ledger` directly. From 31f5d2c07cdb0c773eaaab2fae7067732b47e89c Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Wed, 22 Jul 2026 12:18:32 -0400 Subject: [PATCH 3/4] Re-export ledger TxOut accessors for reading outputs Add addrTxOutL / valueTxOutL (EraTx0ut), datumTxOutF (AlonzoEraTxOut), Datum(..), hashBinaryData, and hashScript to Cardano.Api.Ledger, so downstream code can read a transaction output's address, value, datum and reference script through the ledger lenses. --- .changes/reexport-txauxdata-accessors.yml | 2 +- .../src/Cardano/Api/Ledger/Internal/Reexport.hs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.changes/reexport-txauxdata-accessors.yml b/.changes/reexport-txauxdata-accessors.yml index bcfb2426ee..ed504331ac 100644 --- a/.changes/reexport-txauxdata-accessors.yml +++ b/.changes/reexport-txauxdata-accessors.yml @@ -3,4 +3,4 @@ pr: 1262 kind: - compatible description: | - Re-export the ledger accessors `auxDataTxL` (via `EraTx`) and `metadataTxAuxDataL` (via `EraTxAuxData`) from `Cardano.Api.Ledger`, so downstream code can read a transaction's auxiliary data (metadata) through the ledger lenses without depending on `cardano-ledger` directly. + Re-export additional ledger accessors from `Cardano.Api.Ledger` so downstream code can read a transaction and its outputs through the ledger lenses without depending on `cardano-ledger` directly: `auxDataTxL` (via `EraTx`), `metadataTxAuxDataL` (via `EraTxAuxData`), `addrTxOutL` / `valueTxOutL` (via `EraTxOut`), `datumTxOutF` (via `AlonzoEraTxOut`), plus `Datum (..)`, `hashBinaryData`, and `hashScript`. diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index 12c180f3fe..ac5ed6ca08 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -51,7 +51,7 @@ module Cardano.Api.Ledger.Internal.Reexport , toCompactPartial , EraPParams (..) , Era (..) - , EraTxOut + , EraTxOut (addrTxOutL, valueTxOutL) , Inject (..) , Network (..) , PoolCert (..) @@ -151,6 +151,10 @@ module Cardano.Api.Ledger.Internal.Reexport , AsIx (..) , CoinPerWord (..) , Data (..) + , Datum (..) + , AlonzoEraTxOut (datumTxOutF) + , hashBinaryData + , hashScript , EraTxWits (..) , ExUnits (..) , Redeemers (..) @@ -223,6 +227,7 @@ import Cardano.Ledger.Address (AccountAddress (..), Addr (..)) import Cardano.Ledger.Allegra.Scripts (AllegraEraScript (..), Timelock (..), showTimelock) import Cardano.Ledger.Alonzo.Core ( AlonzoEraScript (..) + , AlonzoEraTxOut (datumTxOutF) , AlonzoEraTxBody (..) , AlonzoEraTxWits (..) , AsIx (..) @@ -350,13 +355,14 @@ import Cardano.Ledger.Core , EraPParams (..) , EraTxAuxData (metadataTxAuxDataL) , EraTxBody (..) - , EraTxOut + , EraTxOut (addrTxOutL, valueTxOutL) , PParams (..) , PoolCert (..) , TopTx , TxOut , Value , fromEraCBOR + , hashScript , mkBasicTxOut , ppMinFeeAL , ppMinUTxOValueL @@ -383,7 +389,7 @@ import Cardano.Ledger.Keys , toVRFVerKeyHash ) import Cardano.Ledger.Mary.Value (MaryValue (..), MultiAsset (..), PolicyID (..), valueFromList) -import Cardano.Ledger.Plutus.Data (Data (..), unData) +import Cardano.Ledger.Plutus.Data (Data (..), Datum (..), hashBinaryData, unData) import Cardano.Ledger.Plutus.Language ( Language , Plutus From 7de17d31d4b0ed266f2ed3fb4f95d02d1bdf3df6 Mon Sep 17 00:00:00 2001 From: Jordan Millar Date: Thu, 30 Jul 2026 11:36:11 -0400 Subject: [PATCH 4/4] Fix fourmolu import ordering and drop redundant test imports Sort the Cardano.Ledger.Alonzo.Core import list: AlonzoEraTxOut after AlonzoEraTxBody, and auxDataTxL first in the EraTx bundle. Re-exporting these accessors from Cardano.Api.Ledger makes two same-alias ledger imports in the test suite fully redundant, which fails the build under -Werror=unused-imports. --- cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs | 4 ++-- .../test/cardano-api-test/Test/Cardano/Api/Experimental.hs | 1 - .../Test/Cardano/Api/Transaction/Body/Plutus/Scripts.hs | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index ac5ed6ca08..defc18a6eb 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -227,14 +227,14 @@ import Cardano.Ledger.Address (AccountAddress (..), Addr (..)) import Cardano.Ledger.Allegra.Scripts (AllegraEraScript (..), Timelock (..), showTimelock) import Cardano.Ledger.Alonzo.Core ( AlonzoEraScript (..) - , AlonzoEraTxOut (datumTxOutF) , AlonzoEraTxBody (..) + , AlonzoEraTxOut (datumTxOutF) , AlonzoEraTxWits (..) , AsIx (..) , AsIxItem (AsIxItem) , CoinPerWord (..) , EraGov - , EraTx (bodyTxL, witsTxL, auxDataTxL) + , EraTx (auxDataTxL, bodyTxL, witsTxL) , EraTxWits (..) , PParamsUpdate (..) , Tx diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs index c413d5e3c7..7ff911c9fe 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Experimental.hs @@ -36,7 +36,6 @@ import Cardano.Ledger.Conway qualified as L import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Dijkstra.Genesis (DijkstraGenesis (..)) import Cardano.Ledger.Mary.Value qualified as Mary -import Cardano.Ledger.Plutus.Data qualified as L import Cardano.Ledger.Plutus.Language qualified as Plutus import Cardano.Slotting.EpochInfo qualified as Slotting import Cardano.Slotting.Slot qualified as Slotting diff --git a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Body/Plutus/Scripts.hs b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Body/Plutus/Scripts.hs index 88a698f83a..2ca5e5070a 100644 --- a/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Body/Plutus/Scripts.hs +++ b/cardano-api/test/cardano-api-test/Test/Cardano/Api/Transaction/Body/Plutus/Scripts.hs @@ -21,7 +21,6 @@ import Cardano.Api.Serialise.Cbor (SerialiseAsCBOR (..)) import Cardano.Ledger.Conway qualified as L import Cardano.Ledger.Conway.Scripts qualified as L -import Cardano.Ledger.Core qualified as L import Cardano.Ledger.Dijkstra.Scripts qualified as L import Cardano.Ledger.Plutus.Language qualified as L