From 0cf77ab987d585f178b3007c1db3831ea8c79672 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Thu, 25 Jul 2024 16:14:08 +0200 Subject: [PATCH] Add `Cardano.Read.Ledger.Tx.Outputs` --- lib/read/lib/Cardano/Read/Ledger/Tx/Output.hs | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 lib/read/lib/Cardano/Read/Ledger/Tx/Output.hs diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Output.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Output.hs new file mode 100644 index 00000000000..5ad75743b13 --- /dev/null +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Output.hs @@ -0,0 +1,58 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE NoMonomorphismRestriction #-} +{-# LANGUAGE ScopedTypeVariables #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE UndecidableInstances #-} + +-- | +-- Copyright: © 2020-2022 IOHK +-- License: Apache-2.0 +-- +-- Raw era-dependent tx output +-- + +module Cardano.Read.Ledger.Tx.Output + ( OutputType + , Output (..) + ) + where + +import Prelude + +import Cardano.Ledger.Alonzo.TxOut + ( AlonzoTxOut + ) +import Cardano.Ledger.Babbage.TxOut + ( BabbageTxOut + ) +import Cardano.Ledger.Shelley.TxOut + ( ShelleyTxOut + ) +import Cardano.Wallet.Read.Eras + ( Allegra + , Alonzo + , Babbage + , Byron + , Conway + , Mary + , Shelley + ) + +import qualified Cardano.Chain.UTxO as BY + +type family OutputType era where + OutputsType Byron = BY.TxOut + OutputsType Shelley = ShelleyTxOut Shelley + OutputsType Allegra = ShelleyTxOut Allegra + OutputsType Mary = ShelleyTxOut Mary + OutputsType Alonzo = AlonzoTxOut Alonzo + OutputsType Babbage = BabbageTxOut Babbage + OutputsType Conway = BabbageTxOut Conway + +newtype Output era = Output (OutputType era) + +deriving instance Show (OutputType era) => Show (Output era) +deriving instance Eq (OutputType era) => Eq (Output era)