Add FromJSON instance for new experimental TxOut#1179
Draft
Add FromJSON instance for new experimental TxOut#1179
Conversation
Add per-era FromJSON instances for the experimental TxOut type, mirroring the ToJSON structure. Pre-Alonzo eras parse address and value only; Alonzo adds datum hash support; Babbage+ adds inline datum (parsed from inlineDatumRaw with hash validation) and reference script support. Supplemental datums are deliberately unsupported as the ledger TxOut does not carry them.
Extract the cast-based value conversion from txOutBaseParseJson into a standalone documented helper. The ledger's Value type family resolves to Coin for Shelley/Allegra and MaryValue for Mary onwards, requiring a runtime type check via Data.Typeable.cast to bridge the gap.
Replace the three separate where-bound helpers (datumFields, inlineDatumFields, refScriptFields) with a single top-level datumAndRefScriptFields function. Simplifies alonzoOnwardsTxOutToJson and documents the per-era field layout in one place.
87cfa8a to
bc2431f
Compare
bc2431f to
9734a72
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
Implements
FromJSONinstances for the newTxOut eratype (which wrapsL.TxOut era) in the experimental API, matching the JSON format produced by theToJSONinstances added in #1176.Closes #926
Changelog
How to trust this PR
FromJSONinstances for each era (Shelley through Conway), mirroring theToJSONstructure from Add ToJSON instance for new experimental TxOut #1176txOutBaseParseJsonhelperdataHashTxOutLinlineDatumRaw(hex-encoded original CBOR bytes) with hash validation againstinlineDatumhash, and reference script parsing viascriptInAnyLangToLedgerScriptaddrFromJson(reverse ofaddrToJson),scriptInAnyLangToLedgerScript(reverse ofledgerScriptToScriptInAnyLang)fromJSON . toJSON = id) across all Shelley-based erasChecklist
fourmolu