Skip to content

Use Exp.TxOut directly in Compatible/TxOut; simplify Byron output types#1392

Open
Jimbo4350 wants to merge 2 commits into
masterfrom
jordan/use-experimental-txout-directly
Open

Use Exp.TxOut directly in Compatible/TxOut; simplify Byron output types#1392
Jimbo4350 wants to merge 2 commits into
masterfrom
jordan/use-experimental-txout-directly

Conversation

@Jimbo4350

@Jimbo4350 Jimbo4350 commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Context

Build Exp.TxOut directly via ledger constructors in Compatible/Transaction/TxOut.hs, removing the TxOut CtxTx era intermediate. Simplify the Byron command path to use (Address ByronAddr, L.Coin) instead of [TxOut CtxTx ByronEra] throughout Byron/{Command,Parser,Run,Tx}.hs.

How to trust this PR

  • cabal build cardano-cli -j4 — clean build
  • cabal test cardano-cli -j4 — all tests pass

Checklist

  • Commit sequence broadly makes sense and commits have useful messages
  • Self-reviewed the diff
  • Changelog fragment added in .changes/

@Jimbo4350 Jimbo4350 force-pushed the jordan/use-experimental-txout-directly branch from 310f0f7 to d1213e6 Compare June 29, 2026 18:49
Comment thread cardano-cli/src/Cardano/CLI/Byron/Parser.hs Fixed
@Jimbo4350 Jimbo4350 force-pushed the jordan/use-experimental-txout-directly branch 4 times, most recently from f23ec80 to 4759b37 Compare June 29, 2026 19:27
@Jimbo4350 Jimbo4350 marked this pull request as ready for review June 29, 2026 19:27
Copilot AI review requested due to automatic review settings June 29, 2026 19:27

Copilot AI left a comment

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.

Pull request overview

Refactors transaction output construction to build Exp.TxOut directly via ledger constructors (removing the intermediate TxOut CtxTx era), and simplifies the Byron command path to represent outputs as (Address ByronAddr, L.Coin).

Changes:

  • Reworked Compatible/Transaction/TxOut.mkTxOut to construct ledger TxOut values directly per-era and return supplemental datum bodies separately.
  • Simplified Byron CLI plumbing to pass outputs as (Address ByronAddr, L.Coin) and adapt them at the transaction-building boundary.
  • Added a changelog fragment documenting the refactor.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
cardano-cli/src/Cardano/CLI/Compatible/Transaction/TxOut.hs Constructs Exp.TxOut directly with ledger constructors/lenses and threads supplemental datum bodies separately.
cardano-cli/src/Cardano/CLI/Byron/Tx.hs Accepts Byron outputs as (Address ByronAddr, L.Coin) and converts to TxOut for makeByronTransactionBody.
cardano-cli/src/Cardano/CLI/Byron/Run.hs Propagates the new Byron output type through command execution.
cardano-cli/src/Cardano/CLI/Byron/Parser.hs Parses --txout as (Address ByronAddr, L.Coin) instead of a full TxOut.
cardano-cli/src/Cardano/CLI/Byron/Command.hs Updates Byron command constructors to use (Address ByronAddr, L.Coin) for outputs.
.changes/20260629_152640_cardano-cli_jordan.millar_use_exp_txout_directly.yml Records the refactor in the changelog system.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +299 to +303
pLovelaceCoin :: Word64 -> L.Coin
pLovelaceCoin l =
if l > (maxBound :: Word64)
then error $ show l <> " lovelace exceeds the Word64 upper bound"
else TxOutValueByron $ L.Coin $ toInteger l
else L.Coin $ toInteger l

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.

Copilot is right. Even though this is a pre-existing error, if we want better errors for out of bound we would need to parse it as an Integer, maybe we need to ensure it is not negative too. If not, then this is just L.Coin . toInteger.

@Jimbo4350 Jimbo4350 force-pushed the jordan/use-experimental-txout-directly branch from 4759b37 to c99fdc4 Compare June 29, 2026 19:57

@palas palas left a comment

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.

It all looks correct to me 👍

Comment on lines +299 to +303
pLovelaceCoin :: Word64 -> L.Coin
pLovelaceCoin l =
if l > (maxBound :: Word64)
then error $ show l <> " lovelace exceeds the Word64 upper bound"
else TxOutValueByron $ L.Coin $ toInteger l
else L.Coin $ toInteger l

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.

Copilot is right. Even though this is a pre-existing error, if we want better errors for out of bound we would need to parse it as an Integer, maybe we need to ensure it is not negative too. If not, then this is just L.Coin . toInteger.

Comment on lines +116 to +117
let dh = unScriptDataHash (hashScriptDataBytes sData)
pure (L.DatumHash dh, Map.singleton dh (toAlonzoData sData))

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.

Could use the same approach here and in lines 96-98 for added consistency

@Jimbo4350 Jimbo4350 force-pushed the jordan/use-experimental-txout-directly branch from c9d0228 to 8f88aae Compare June 30, 2026 17:26
- pLovelaceCoin: parse lovelace as Integer; reject negatives and values
  exceeding the Word64 upper bound with clear error messages (matching
  the pattern used by parseLovelaceAtto elsewhere in this file)
- babbageDatumFields TxOutDatumByValue: convert to ledger data first then hash,
  matching alonzoDatumFields pattern and avoiding a redundant toAlonzoData call
@Jimbo4350 Jimbo4350 force-pushed the jordan/use-experimental-txout-directly branch from 8f88aae to 6bde6c1 Compare June 30, 2026 17:31
@Jimbo4350 Jimbo4350 enabled auto-merge June 30, 2026 17:32
@Jimbo4350 Jimbo4350 added this pull request to the merge queue Jun 30, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jun 30, 2026
@Jimbo4350 Jimbo4350 added this pull request to the merge queue Jul 1, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 1, 2026
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