Skip to content

TxBodyContent refactoring related fixes#1093

Open
Jimbo4350 wants to merge 6 commits intomasterfrom
jordan/tx-body-content-refactoring-fixes
Open

TxBodyContent refactoring related fixes#1093
Jimbo4350 wants to merge 6 commits intomasterfrom
jordan/tx-body-content-refactoring-fixes

Conversation

@Jimbo4350
Copy link
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
@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 6 times, most recently from 6f0764f to 294ecd9 Compare January 29, 2026 19:10
@Jimbo4350 Jimbo4350 force-pushed the jordan/tx-body-content-refactoring-fixes branch from 294ecd9 to b210b64 Compare January 30, 2026 15:25
Copy link
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 on lines +753 to +758
substitudeExecUnitsTxMint
:: ScriptWitnessIndex
-> AnyScriptWitness (LedgerEra era)
-> Either (TxBodyErrorAutoBalance (LedgerEra era)) (AnyScriptWitness (LedgerEra era))
substitudeExecUnitsTxMint _ w@AnyScriptWitnessSimple{} = Right w
substitudeExecUnitsTxMint idx (AnyScriptWitnessPlutus psw) =
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
substitudeExecUnitsTxMint
:: ScriptWitnessIndex
-> AnyScriptWitness (LedgerEra era)
-> Either (TxBodyErrorAutoBalance (LedgerEra era)) (AnyScriptWitness (LedgerEra era))
substitudeExecUnitsTxMint _ w@AnyScriptWitnessSimple{} = Right w
substitudeExecUnitsTxMint idx (AnyScriptWitnessPlutus psw) =
substituteExecUnitsTxMint
:: ScriptWitnessIndex
-> AnyScriptWitness (LedgerEra era)
-> Either (TxBodyErrorAutoBalance (LedgerEra era)) (AnyScriptWitness (LedgerEra era))
substituteExecUnitsTxMint _ w@AnyScriptWitnessSimple{} = Right w
substituteExecUnitsTxMint idx (AnyScriptWitnessPlutus psw) =

Typo substitudeExecUnitsTxMint -> substituteExecUnitsTxMint

[ (policyId, (assets,) <$> substitutedWitness)
| (ix, policyId, assets, wit) <- indexTxMintValue txMintValue'
, let substitutedWitness = substituteExecUnits ix wit
, let substitutedWitness = substitudeExecUnitsTxMint ix wit
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
, let substitutedWitness = substitudeExecUnitsTxMint ix wit
, let substitutedWitness = substituteExecUnitsTxMint ix wit

Also here

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
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.

newDatum :: L.Datum (LedgerEra era) <- obtainCommonConstraints (useEra @era) $ toLedgerDatum d
return $ obtainCommonConstraints (useEra @era) $ TxOut $ o & L.datumTxOutL .~ newDatum

newtype DatumDecodingError = DataDecodingError String
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the type name and the constructor names are slightly different?

proxyToAsType _ = AsConwayEra

instance HasTypeProxy L.DijkstraEra where
data AsType L.DijkstraEra = AsDijkstraEra
Copy link
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?

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.

3 participants