Use Exp.TxOut directly in Compatible/TxOut; simplify Byron output types#1392
Use Exp.TxOut directly in Compatible/TxOut; simplify Byron output types#1392Jimbo4350 wants to merge 2 commits into
Conversation
310f0f7 to
d1213e6
Compare
f23ec80 to
4759b37
Compare
There was a problem hiding this comment.
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.mkTxOutto construct ledgerTxOutvalues 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.
| 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 |
There was a problem hiding this comment.
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.
4759b37 to
c99fdc4
Compare
| 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 |
There was a problem hiding this comment.
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.
| let dh = unScriptDataHash (hashScriptDataBytes sData) | ||
| pure (L.DatumHash dh, Map.singleton dh (toAlonzoData sData)) |
There was a problem hiding this comment.
Could use the same approach here and in lines 96-98 for added consistency
c9d0228 to
8f88aae
Compare
- 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
8f88aae to
6bde6c1
Compare
Context
Build
Exp.TxOutdirectly via ledger constructors inCompatible/Transaction/TxOut.hs, removing theTxOut CtxTx eraintermediate. Simplify the Byron command path to use(Address ByronAddr, L.Coin)instead of[TxOut CtxTx ByronEra]throughoutByron/{Command,Parser,Run,Tx}.hs.How to trust this PR
cabal build cardano-cli -j4— clean buildcabal test cardano-cli -j4— all tests passChecklist
.changes/