Skip to content

Deprecate eon-parameterized lenses in favour of direct ledger lenses#1159

Closed
Jimbo4350 wants to merge 1 commit into
masterfrom
deprecate-eon-lenses-938
Closed

Deprecate eon-parameterized lenses in favour of direct ledger lenses#1159
Jimbo4350 wants to merge 1 commit into
masterfrom
deprecate-eon-lenses-938

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

Changelog

- description: |
    Replace eon-parameterized lenses with direct ledger lenses and era constraints
  type:
   - refactoring
  projects:
   - cardano-api

Context

Resolves #938

Cardano.Api.Tx.Internal.Body.Lens contains lenses that take an eon witness parameter (e.g. reqSignerHashesTxBodyL :: AlonzoEraOnwards era -> Lens' ...). This PR replaces those with direct use of ledger lenses (L.vldtTxBodyL, L.mintTxBodyL, L.collateralInputsTxBodyL, etc.) composed with the appropriate era constraints at each call site.

Key changes:

  • Use L.ttlTxBodyL / L.vldtTxBodyL directly instead of invalidHereAfterTxBodyL / invalidBeforeTxBodyL
  • Use L.mintTxBodyL, L.collateralInputsTxBodyL, L.reqSignerHashesTxBodyL, etc. directly
  • Replace adaAssetL / multiAssetL with inline lens in negateLedgerValue
  • Update L.Witness -> L.Guard (ledger API rename)
  • Remove duplicate Dijkstra era branches in Output.hs

How to trust this PR

WIP — not yet formatted or build-verified. Review the diff for correctness of lens replacements and era constraint placement.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated
  • Self-reviewed the diff
  • Fourmolu formatted
  • Build verified

Replace custom eon lenses from Cardano.Api.Tx.Internal.Body.Lens with
direct ledger lenses (L.vldtTxBodyL, L.invalidBeforeL, etc.) composed
with era constraints. This removes the indirection layer where each
lens required an eon witness parameter.

Key changes:
- Use L.ttlTxBodyL / L.vldtTxBodyL directly instead of
  invalidHereAfterTxBodyL / invalidBeforeTxBodyL
- Use L.mintTxBodyL, L.collateralInputsTxBodyL, etc. directly
- Replace adaAssetL/multiAssetL with inline lens in negateLedgerValue
- Update L.Witness -> L.Guard (ledger API rename)
- Remove duplicate Dijkstra era branches in Output.hs

Resolves: #938
@Jimbo4350
Copy link
Copy Markdown
Contributor Author

Closing — this work is superseded by the full old-API removal in #1094.

@Jimbo4350 Jimbo4350 closed this Mar 26, 2026
createTransactionBody sbe bc =
shelleyBasedEraConstraints sbe $ do
(sData, mScriptIntegrityHash, scripts) <-
(sData, (mScriptIntegrityHash :: StrictMaybe L.ScriptIntegrityHash), scripts) <-

Check notice

Code scanning / HLint

Redundant bracket Note

cardano-api/src/Cardano/Api/Tx/Internal/Body.hs:1275:13-71: Suggestion: Redundant bracket
  
Found:
  (sData,
   (mScriptIntegrityHash :: StrictMaybe L.ScriptIntegrityHash),
   scripts)
  
Perhaps:
  (sData, mScriptIntegrityHash :: StrictMaybe L.ScriptIntegrityHash,
   scripts)
TxOutValueShelleyBased sbe v -> v ^. A.adaAssetL sbe
TxOutValueShelleyBased sbe v ->
caseShelleyToAllegraOrMaryEraOnwards
(\w -> shelleyToAllegraEraConstraints w v)

Check notice

Code scanning / HLint

Avoid lambda using `infix` Note

cardano-api/src/Cardano/Api/Tx/Internal/Output.hs:1012:9-50: Suggestion: Avoid lambda using infix
  
Found:
  (\ w -> shelleyToAllegraEraConstraints w v)
  
Perhaps:
  (shelleyToAllegraEraConstraints v)
@Jimbo4350 Jimbo4350 deleted the deprecate-eon-lenses-938 branch May 7, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deprecate all lenses that use the eon api

2 participants