Re-export the full Value API from V2/V3 and the Data.* modules#7839
Conversation
There was a problem hiding this comment.
Pull request overview
This PR expands the “umbrella” ledger API modules (PlutusLedgerApi.V2, PlutusLedgerApi.V3, and PlutusLedgerApi.Data.V1/V2/V3) to re-export the same Value-related surface area that PlutusLedgerApi.V1 already provides, so downstream users don’t need extra V1.Value / V1.Data.Value imports for common accessors and helpers.
Changes:
- Re-export the full
Valueaccessor/helper API (e.g.valueOf,lovelaceValueOf,unsafeLovelaceValueOf,flattenValue,AssetClasshelpers) fromV2,V3, andData.V*umbrella modules. - Remove now-redundant downstream imports that became unused under
-Werror=unused-imports. - Add a changelog fragment documenting the re-export expansion.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| plutus-ledger-api/src/PlutusLedgerApi/V2.hs | Extends V2 umbrella exports to include the full Value API re-exported from V1. |
| plutus-ledger-api/src/PlutusLedgerApi/V3.hs | Extends V3 umbrella exports to include the full Value API re-exported from V2. |
| plutus-ledger-api/src/PlutusLedgerApi/Data/V1.hs | Extends Data.V1 umbrella exports to include the full Value API from V1.Data.Value. |
| plutus-ledger-api/src/PlutusLedgerApi/Data/V2.hs | Extends Data.V2 umbrella exports to include the full Value API re-exported from Data.V1. |
| plutus-ledger-api/src/PlutusLedgerApi/Data/V3.hs | Extends Data.V3 umbrella exports to include the full Value API re-exported from Data.V2. |
| plutus-ledger-api/changelog.d/20260710_100000_yuriy.lazaryev_value_umbrella_reexports.md | Changelog entry documenting the expanded umbrella-module re-exports. |
| plutus-benchmark/script-contexts/src/PlutusBenchmark/V1/Data/ScriptContexts.hs | Drops redundant PlutusLedgerApi.V1.Data.Value import now covered by PlutusLedgerApi.Data.V1. |
| plutus-benchmark/script-contexts/src/PlutusBenchmark/V2/Data/ScriptContexts.hs | Drops redundant PlutusLedgerApi.V1.Data.Value import now covered by PlutusLedgerApi.Data.V2. |
| plutus-benchmark/cardano-loans/src/CardanoLoans/Validator.hs | Drops redundant PlutusLedgerApi.V1.Value (valueOf) import now covered by PlutusLedgerApi.V3. |
|
Done — swept the repo for the same pattern. The modules that still needed |
|
PlutusLedgerApi.V2, V3, and Data.V1/V2/V3 now re-export the same Value API that PlutusLedgerApi.V1 already exposed: the read accessors (valueOf, lovelaceValueOf, unsafeLovelaceValueOf, currencySymbolValueOf, assetClassValueOf), the AssetClass type and its constructors, and the helpers flattenValue, symbols, isZero, split, scale, lovelaceValue, currencySymbol, tokenName. Previously these umbrella modules exposed only the Value type and a few constructors, so reading a value from a V2/V3 or Data.* context needed a separate import from V1.Value or V1.Data.Value. There is no per-version Value type (V2 re-exports V1.Value, V3 re-exports V2.Value, and the Data.* chain mirrors that), so the accessors apply unchanged. Widening the re-exports made three explicit imports redundant under -Werror=unused-imports; removed them: import ...V1.Value (valueOf) in cardano-loans, and the whole-module ...V1.Data.Value imports in script-contexts V1.Data and V2.Data ScriptContexts. Stacked on the unsafeLovelaceValueOf branch (#7838), which adds the accessor this widening re-exports.
… remaining V1.Value imports
e3f9302 to
57a983f
Compare
PlutusLedgerApi.V2,PlutusLedgerApi.V3, andPlutusLedgerApi.Data.V1/V2/V3now re-export the fullValueAPI thatPlutusLedgerApi.V1already exposed, and all six umbrellas (includingV1) additionally exposegeq,gt,leq,lt, andwithCurrencySymbol, which previously lived only inPlutusLedgerApi.V1.Value/.Data.Value. Reading or comparing aValuefrom a version umbrella no longer needs a directPlutusLedgerApi.V1.ValueorPlutusLedgerApi.V1.Data.Valueimport. Every V2/V3 module in this repo that reached into those V1 modules now uses the umbrella instead; the remaining direct importers are genuine V1 code (the V1 doc examples, thescript-contextsV1 variant) and the V1Valuetest suites.