IntersectMBO / cardano-node

The core component that is used to participate in a Cardano decentralised blockchain.
https://cardano.org
Apache License 2.0
3.06k stars 722 forks source link

[FR] - Casting `Tx era` to `TxForMode mode` #1858

Closed deepfire closed 1 year ago

deepfire commented 4 years ago

Internal

Describe the feature you'd like

A cardano-api function with a signature similar to: castTxMode :: Mode mode era -> Tx era -> TxForMode mode.

Note that (similarly to #1853, #1859, #1861) the type of the first argument (the indexed GADT Mode) does not currently exist in cardano-api -- but exists in the generator.

This function is currently implemented in the generator as:

castTxMode ModeByron{}          tx@ByronTx{}   = TxForByronMode  tx
castTxMode ModeShelley{}        tx@ShelleyTx{} = TxForShelleyMode tx
castTxMode ModeCardanoByron{}   tx@ByronTx{}   = TxForCardanoMode $ Left tx
castTxMode ModeCardanoShelley{} tx@ShelleyTx{} = TxForCardanoMode $ Right tx
Jimbo4350 commented 1 year ago

Closing this. If this is still relevant please re-open.