From 2a19a3ade918aa3e75c56ebda6df78f675f725bf 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 bc10ce4fae..6d99276818 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -181,7 +181,8 @@ module Cardano.Api.Ledger.Internal.Reexport , pattern AlonzoGenesis , AsIxItem (..) , EraGov - , EraTx (witsTxL, bodyTxL) + , EraTx (witsTxL, bodyTxL, auxDataTxL) + , EraTxAuxData (metadataTxAuxDataL) , EraTxBody (..) , TopTx , Tx @@ -246,7 +247,7 @@ import Cardano.Ledger.Alonzo.Core , AsIxItem (AsIxItem) , CoinPerWord (..) , EraGov - , EraTx (bodyTxL, witsTxL) + , EraTx (bodyTxL, witsTxL, auxDataTxL) , EraTxWits (..) , PParamsUpdate (..) , Tx @@ -381,6 +382,7 @@ import Cardano.Ledger.Conway.TxCert import Cardano.Ledger.Core ( Era (..) , EraPParams (..) + , EraTxAuxData (metadataTxAuxDataL) , EraTxBody (..) , EraTxOut , PParams (..) From 11596cce2996cff59e413e4cfe81ca6bc73417b1 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 a02f4fe9e3335411c62679e3e3867b59e6ece6dd 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 6d99276818..22a719096f 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 (..) @@ -169,6 +169,10 @@ module Cardano.Api.Ledger.Internal.Reexport , AsIx (..) , CoinPerWord (..) , Data (..) + , Datum (..) + , AlonzoEraTxOut (datumTxOutF) + , hashBinaryData + , hashScript , EraTxWits (..) , ExUnits (..) , Redeemers (..) @@ -241,6 +245,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 (..) @@ -384,13 +389,14 @@ import Cardano.Ledger.Core , EraPParams (..) , EraTxAuxData (metadataTxAuxDataL) , EraTxBody (..) - , EraTxOut + , EraTxOut (addrTxOutL, valueTxOutL) , PParams (..) , PoolCert (..) , TopTx , TxOut , Value , fromEraCBOR + , hashScript , mkBasicTxOut , ppMinFeeAL , ppMinUTxOValueL @@ -418,7 +424,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 b89bf787cf6abf74b5dc41973c758178c629e20b 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 | 6 ++---- .../test/cardano-api-test/Test/Cardano/Api/Experimental.hs | 1 - .../Test/Cardano/Api/Transaction/Body/Plutus/Scripts.hs | 1 - 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs index 22a719096f..7c7741f806 100644 --- a/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs +++ b/cardano-api/src/Cardano/Api/Ledger/Internal/Reexport.hs @@ -74,7 +74,6 @@ module Cardano.Api.Ledger.Internal.Reexport , getScriptsNeeded , mkBasicTxOut , coinTxOutL - , valueTxOutL , toDeltaCoin , toEraCBOR , toSLanguage @@ -245,14 +244,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 @@ -292,7 +291,6 @@ import Cardano.Ledger.Api , treasuryDonationTxBodyL , unRedeemers , updateTxBodyL - , valueTxOutL , votingProceduresTxBodyL ) import Cardano.Ledger.Api.Tx.Cert 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 0c4720fbd9..c23461d13b 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 031a51d254..d6e0aa4f49 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