Skip to content

TxBodyContent refactoring related fixes#1093

Merged
Jimbo4350 merged 7 commits intomasterfrom
jordan/tx-body-content-refactoring-fixes
Feb 11, 2026
Merged

TxBodyContent refactoring related fixes#1093
Jimbo4350 merged 7 commits intomasterfrom
jordan/tx-body-content-refactoring-fixes

Conversation

@Jimbo4350
Copy link
Copy Markdown
Contributor

@Jimbo4350 Jimbo4350 commented Jan 28, 2026

Changelog

Resolves:

- description: |
    TxBodyContent refactoring related fixes
  type:
  - breaking      

  projects:
   - cardano-api

Context

Additional context for the PR goes here. If the PR fixes a particular issue please provide a link to the issue.

How to trust this PR

Highlight important bits of the PR that will make the review faster. If there are commands the reviewer can run to observe the new behavior, describe them.

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • New tests are added if needed and existing tests are updated. See Running tests for more details
  • Self-reviewed the diff

@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch 2 times, most recently from 2f27bcb to 94d2bf5 Compare January 28, 2026 20:44
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs Outdated
@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch from a4bf7e5 to b849b1e Compare January 29, 2026 14:16
@Jimbo4350 Jimbo4350 marked this pull request as ready for review January 29, 2026 14:16
@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch from b849b1e to 5595edb Compare January 29, 2026 14:40
@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch 7 times, most recently from 294ecd9 to b210b64 Compare January 30, 2026 15:25
Copy link
Copy Markdown
Contributor

@palas palas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍. Just a typo and a suggestion

Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs Outdated
Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs Outdated
Comment on lines +759 to +765
case Map.lookup idx exUnitsMap of
Nothing ->
Left $ TxBodyErrorScriptWitnessIndexMissingFromExecUnitsMap idx exUnitsMap
Just exunits ->
Right $
AnyScriptWitnessPlutus $
updatePlutusScriptWitnessExecutionUnits exunits psw
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit should probably be a separate function because it is identical to the bit in substituteExecUnits. Maybe substituteExecUnitsInPsw.

Copy link
Copy Markdown
Contributor Author

@Jimbo4350 Jimbo4350 Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not, they return different types unless I'm misunderstanding what you're referring to.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you are right, I hadn't seen that. But still, you could probably abstract everything but the AnyScriptWitnessPlutus / AnyPlutusScriptWitness constructor call, and do it outside of substituteExecUnitsInPsw with fmap. Your call though

Copy link
Copy Markdown
Contributor Author

@Jimbo4350 Jimbo4350 Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I pushed the refactor, thanks.

Comment thread cardano-api/src/Cardano/Api/Experimental/Tx/Internal/BodyContent/New.hs Outdated
proxyToAsType _ = AsConwayEra

instance HasTypeProxy L.DijkstraEra where
data AsType L.DijkstraEra = AsDijkstraEra
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have not exported the name constructors here. Additionally, there would be a name clash between definitions of our eras and ledger eras, since the constructors have the same name: https://github.com/IntersectMBO/cardano-api/blob/mgalazyn/proto-lens-ghc-9.12/cardano-api/src/Cardano/Api/Era/Internal/Core.hs#L108-L108

Perhaps it's the sign to switch to using ledger eras everywhere?

Copy link
Copy Markdown
Contributor Author

@Jimbo4350 Jimbo4350 Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should switch to using the ledger's type level era tags in the future but I think I found a better solution for now.

@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch 5 times, most recently from 176b5a0 to 06fd44c Compare February 10, 2026 12:35
@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch from 06fd44c to c0f90ed Compare February 10, 2026 12:37
@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch from c0f90ed to 02f3830 Compare February 10, 2026 13:34
ToApiEra L.MaryEra = Api.MaryEra
ToApiEra L.AllegraEra = Api.AllegraEra
ToApiEra L.ShelleyEra = Api.ShelleyEra
ToApiEra L.ByronEra = Api.ByronEra
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of duplicating translation between two types, but I guess for a temporary measure this is fine.

@Jimbo4350 Jimbo4350 added this pull request to the merge queue Feb 11, 2026
Merged via the queue into master with commit f686e52 Feb 11, 2026
29 checks passed
@Jimbo4350 Jimbo4350 deleted the jordan/tx-body-content-refactoring-fixes branch February 11, 2026 20:51
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.

4 participants