From 387eac558bab29263927f9f8ab2c0904f970edad Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Mon, 5 Aug 2024 13:16:38 +0200 Subject: [PATCH 1/3] Add `Cardano.Read.Ledger.Eras.KnownEras` --- lib/read/cardano-wallet-read.cabal | 1 + .../lib/Cardano/Read/Ledger/Eras/KnownEras.hs | 92 +++++++++++++++++++ 2 files changed, 93 insertions(+) create mode 100644 lib/read/lib/Cardano/Read/Ledger/Eras/KnownEras.hs diff --git a/lib/read/cardano-wallet-read.cabal b/lib/read/cardano-wallet-read.cabal index 083f1f23720..f49f3b64788 100644 --- a/lib/read/cardano-wallet-read.cabal +++ b/lib/read/cardano-wallet-read.cabal @@ -50,6 +50,7 @@ library Cardano.Read.Ledger.Block.HeaderHash Cardano.Read.Ledger.Block.SlotNo Cardano.Read.Ledger.Block.Txs + Cardano.Read.Ledger.Eras.KnownEras Cardano.Read.Ledger.Tx.Inputs Cardano.Read.Ledger.Tx.Outputs Cardano.Read.Ledger.Tx.TxId diff --git a/lib/read/lib/Cardano/Read/Ledger/Eras/KnownEras.hs b/lib/read/lib/Cardano/Read/Ledger/Eras/KnownEras.hs new file mode 100644 index 00000000000..08d47c14ee4 --- /dev/null +++ b/lib/read/lib/Cardano/Read/Ledger/Eras/KnownEras.hs @@ -0,0 +1,92 @@ +{-# LANGUAGE DataKinds #-} +{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE GADTs #-} +{-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE TypeFamilies #-} + +{- | +Copyright: © 2020-2022 IOHK, 2024 Cardano Foundation +License: Apache-2.0 + +A type list of known eras, useful for indexing types by era. +-} +module Cardano.Read.Ledger.Eras.KnownEras + ( Era (..) + , IsEra (..) + + , KnownEras + , knownEraIndices + , indexOfEra + + , Allegra + , Alonzo + , Babbage + , Byron + , Conway + , Mary + , Shelley + ) where + +import Prelude + +import Cardano.Ledger.Api + ( Allegra + , Alonzo + , Babbage + , ByronEra + , Conway + , Mary + , Shelley + , StandardCrypto + ) +import Generics.SOP + ( Proxy (..) + , lengthSList + ) + +type Byron = ByronEra StandardCrypto + +-- | Singleton type for eras. +-- +-- This GADT provides a value-level representation of eras. +data Era era where + Byron :: Era Byron + Shelley :: Era Shelley + Allegra :: Era Allegra + Mary :: Era Mary + Alonzo :: Era Alonzo + Babbage :: Era Babbage + Conway :: Era Conway + +deriving instance Show (Era era) + +-- | Singleton class for eras. +class IsEra era where + theEra :: Era era + +instance IsEra Byron where theEra = Byron +instance IsEra Shelley where theEra = Shelley +instance IsEra Allegra where theEra = Allegra +instance IsEra Mary where theEra = Mary +instance IsEra Alonzo where theEra = Alonzo +instance IsEra Babbage where theEra = Babbage +instance IsEra Conway where theEra = Conway + +-- | Type-level list of known eras, in chronological order. +type KnownEras = + '[Byron, Shelley, Allegra, Mary, Alonzo, Babbage, Conway] + +-- | Official numbering of the 'KnownEras'. +knownEraIndices :: [Int] +knownEraIndices = [0 .. lengthSList (Proxy :: Proxy KnownEras) - 1] + +-- | Official number of the member of 'KnownEras'. +indexOfEra :: Era era -> Int +indexOfEra e = case e of + Byron -> 0 + Shelley -> 1 + Allegra -> 2 + Mary -> 3 + Alonzo -> 4 + Babbage -> 5 + Conway -> 6 From b281e03b3a6191aee98a52bbea81b7f38e610df2 Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Mon, 5 Aug 2024 13:32:37 +0200 Subject: [PATCH 2/3] Add `Cardano.Read.Ledger.Eras` --- lib/read/cardano-wallet-read.cabal | 1 + lib/read/lib/Cardano/Read/Ledger/Eras.hs | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 lib/read/lib/Cardano/Read/Ledger/Eras.hs diff --git a/lib/read/cardano-wallet-read.cabal b/lib/read/cardano-wallet-read.cabal index f49f3b64788..e821815777f 100644 --- a/lib/read/cardano-wallet-read.cabal +++ b/lib/read/cardano-wallet-read.cabal @@ -50,6 +50,7 @@ library Cardano.Read.Ledger.Block.HeaderHash Cardano.Read.Ledger.Block.SlotNo Cardano.Read.Ledger.Block.Txs + Cardano.Read.Ledger.Eras Cardano.Read.Ledger.Eras.KnownEras Cardano.Read.Ledger.Tx.Inputs Cardano.Read.Ledger.Tx.Outputs diff --git a/lib/read/lib/Cardano/Read/Ledger/Eras.hs b/lib/read/lib/Cardano/Read/Ledger/Eras.hs new file mode 100644 index 00000000000..728610f1bf9 --- /dev/null +++ b/lib/read/lib/Cardano/Read/Ledger/Eras.hs @@ -0,0 +1,9 @@ +{- | +Copyright: © 2024 Cardano Foundation +License: Apache-2.0 +-} +module Cardano.Ledger.Read.Eras + ( module Cardano.Read.Ledger.Eras.KnownEras + ) where + +import Cardano.Read.Ledger.Eras.KnownEras From 95096bba35e01b87c00a7e34abe188c4c7c11f1e Mon Sep 17 00:00:00 2001 From: Heinrich Apfelmus Date: Mon, 5 Aug 2024 13:48:07 +0200 Subject: [PATCH 3/3] Use `Cardano.Read.Ledger.Eras` in `Cardano.Read.Ledger.*` --- lib/read/cardano-wallet-read.cabal | 1 - .../lib/Cardano/Read/Ledger/Block/BHeader.hs | 2 +- .../lib/Cardano/Read/Ledger/Block/Block.hs | 6 +- .../lib/Cardano/Read/Ledger/Block/BlockNo.hs | 2 +- .../Cardano/Read/Ledger/Block/HeaderHash.hs | 2 +- .../lib/Cardano/Read/Ledger/Block/SlotNo.hs | 2 +- lib/read/lib/Cardano/Read/Ledger/Block/Txs.hs | 2 +- lib/read/lib/Cardano/Read/Ledger/Eras.hs | 2 +- lib/read/lib/Cardano/Read/Ledger/Tx/CBOR.hs | 6 +- .../lib/Cardano/Read/Ledger/Tx/Cardano.hs | 6 +- .../Cardano/Read/Ledger/Tx/Certificates.hs | 8 +- .../Read/Ledger/Tx/CollateralInputs.hs | 8 +- .../Read/Ledger/Tx/CollateralOutputs.hs | 8 +- .../lib/Cardano/Read/Ledger/Tx/ExtraSigs.hs | 8 +- lib/read/lib/Cardano/Read/Ledger/Tx/Fee.hs | 8 +- lib/read/lib/Cardano/Read/Ledger/Tx/Hash.hs | 8 +- lib/read/lib/Cardano/Read/Ledger/Tx/Inputs.hs | 8 +- .../lib/Cardano/Read/Ledger/Tx/Integrity.hs | 8 +- .../lib/Cardano/Read/Ledger/Tx/Metadata.hs | 8 +- lib/read/lib/Cardano/Read/Ledger/Tx/Mint.hs | 8 +- .../lib/Cardano/Read/Ledger/Tx/Outputs.hs | 8 +- .../Cardano/Read/Ledger/Tx/ReferenceInputs.hs | 8 +- .../Cardano/Read/Ledger/Tx/ScriptValidity.hs | 8 +- lib/read/lib/Cardano/Read/Ledger/Tx/TxId.hs | 14 ++-- .../lib/Cardano/Read/Ledger/Tx/Validity.hs | 8 +- .../lib/Cardano/Read/Ledger/Tx/Withdrawals.hs | 8 +- .../lib/Cardano/Read/Ledger/Tx/Witnesses.hs | 8 +- lib/read/lib/Cardano/Read/Ledger/Value.hs | 2 +- lib/read/lib/Cardano/Wallet/Read/Eras.hs | 24 +++--- .../lib/Cardano/Wallet/Read/Eras/EraFun.hs | 6 +- .../lib/Cardano/Wallet/Read/Eras/EraValue.hs | 2 +- .../lib/Cardano/Wallet/Read/Eras/KnownEras.hs | 79 ------------------- 32 files changed, 106 insertions(+), 180 deletions(-) delete mode 100644 lib/read/lib/Cardano/Wallet/Read/Eras/KnownEras.hs diff --git a/lib/read/cardano-wallet-read.cabal b/lib/read/cardano-wallet-read.cabal index e821815777f..d800820acd3 100644 --- a/lib/read/cardano-wallet-read.cabal +++ b/lib/read/cardano-wallet-read.cabal @@ -85,7 +85,6 @@ library Cardano.Wallet.Read.Eras Cardano.Wallet.Read.Eras.EraFun Cardano.Wallet.Read.Eras.EraValue - Cardano.Wallet.Read.Eras.KnownEras Cardano.Wallet.Read.Hash Cardano.Wallet.Read.Tx Cardano.Wallet.Read.Tx.Gen diff --git a/lib/read/lib/Cardano/Read/Ledger/Block/BHeader.hs b/lib/read/lib/Cardano/Read/Ledger/Block/BHeader.hs index 56238fceb97..15692d9f59d 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Block/BHeader.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Block/BHeader.hs @@ -28,7 +28,7 @@ import Cardano.Ledger.Block import Cardano.Read.Ledger.Block.Block ( Block (..) ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage diff --git a/lib/read/lib/Cardano/Read/Ledger/Block/Block.hs b/lib/read/lib/Cardano/Read/Ledger/Block/Block.hs index 98bb604a93f..51cbe7376f8 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Block/Block.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Block/Block.hs @@ -24,17 +24,19 @@ import Prelude import Cardano.Ledger.Api ( StandardCrypto ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage , Byron , Conway , Era (..) - , EraValue (..) , IsEra (..) , Mary , Shelley + ) +import Cardano.Wallet.Read.Eras + ( EraValue (..) , eraValue ) import Ouroboros.Consensus.Protocol.Praos diff --git a/lib/read/lib/Cardano/Read/Ledger/Block/BlockNo.hs b/lib/read/lib/Cardano/Read/Ledger/Block/BlockNo.hs index 0be578921db..6dde93d51c7 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Block/BlockNo.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Block/BlockNo.hs @@ -16,7 +16,7 @@ import Prelude import Cardano.Read.Ledger.Block.BHeader ( BHeader (..) ) -import Cardano.Wallet.Read.Eras.KnownEras +import Cardano.Read.Ledger.Eras ( Era (..) , IsEra (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Block/HeaderHash.hs b/lib/read/lib/Cardano/Read/Ledger/Block/HeaderHash.hs index f9e48121de2..88bf1d8242c 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Block/HeaderHash.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Block/HeaderHash.hs @@ -43,7 +43,7 @@ import Cardano.Protocol.TPraos.BHeader import Cardano.Read.Ledger.Block.Block ( Block (..) ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage diff --git a/lib/read/lib/Cardano/Read/Ledger/Block/SlotNo.hs b/lib/read/lib/Cardano/Read/Ledger/Block/SlotNo.hs index f99c4c26d11..374dcd46d51 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Block/SlotNo.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Block/SlotNo.hs @@ -15,7 +15,7 @@ import Prelude import Cardano.Read.Ledger.Block.BHeader ( BHeader (..) ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Era (..) , IsEra (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Block/Txs.hs b/lib/read/lib/Cardano/Read/Ledger/Block/Txs.hs index 2cf534f2695..4d8c22d0d32 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Block/Txs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Block/Txs.hs @@ -15,7 +15,7 @@ import Cardano.Ledger.Binary import Cardano.Read.Ledger.Block.Block ( Block (..) ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Byron , Era (..) , IsEra (..) diff --git a/lib/read/lib/Cardano/Read/Ledger/Eras.hs b/lib/read/lib/Cardano/Read/Ledger/Eras.hs index 728610f1bf9..efbdaceb033 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Eras.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Eras.hs @@ -2,7 +2,7 @@ Copyright: © 2024 Cardano Foundation License: Apache-2.0 -} -module Cardano.Ledger.Read.Eras +module Cardano.Read.Ledger.Eras ( module Cardano.Read.Ledger.Eras.KnownEras ) where diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/CBOR.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/CBOR.hs index 7e0f0bdf3f2..6faa2954d3e 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/CBOR.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/CBOR.hs @@ -41,10 +41,12 @@ import Cardano.Ledger.Binary.Decoding , decodeFullAnnotator , shelleyProtVer ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Era (..) - , EraValue , IsEra (..) + ) +import Cardano.Wallet.Read.Eras + ( EraValue , K (..) , applyEraFunValue , extractEraValue diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Cardano.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Cardano.hs index 4c49c9faaa9..fbdd9dba22c 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Cardano.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Cardano.hs @@ -14,14 +14,16 @@ module Cardano.Read.Ledger.Tx.Cardano import Prelude -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage , Conway - , EraValue , Mary , Shelley + ) +import Cardano.Wallet.Read.Eras + ( EraValue (..) , eraValue ) import Cardano.Wallet.Read.Tx diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Certificates.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Certificates.hs index 096eeb60fb1..f33db467b74 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Certificates.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Certificates.hs @@ -34,10 +34,7 @@ import Cardano.Ledger.Conway.TxCert import Cardano.Ledger.Shelley.TxCert ( ShelleyTxCert ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -48,6 +45,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralInputs.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralInputs.hs index a0787f83025..e1158f45421 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralInputs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralInputs.hs @@ -30,10 +30,7 @@ import Cardano.Ledger.Api import Cardano.Ledger.Core ( bodyTxL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -44,6 +41,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralOutputs.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralOutputs.hs index 6f462ca9a7e..21dd5ee1d74 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralOutputs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/CollateralOutputs.hs @@ -39,10 +39,7 @@ import Cardano.Ledger.Babbage.TxBody import Cardano.Ledger.Core ( bodyTxL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -53,6 +50,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/ExtraSigs.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/ExtraSigs.hs index 714947b9eb0..becaf32a40d 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/ExtraSigs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/ExtraSigs.hs @@ -31,10 +31,7 @@ import Cardano.Ledger.Keys ( KeyHash , KeyRole (..) ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -45,6 +42,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Fee.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Fee.hs index 967915cedeb..487823bcbbe 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Fee.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Fee.hs @@ -30,10 +30,7 @@ import Cardano.Ledger.Core ( bodyTxL , feeTxBodyL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -44,6 +41,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Hash.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Hash.hs index 207833ab459..a7650e6a160 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Hash.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Hash.hs @@ -36,16 +36,16 @@ import Cardano.Ledger.Core import Cardano.Ledger.TxIn ( TxId (..) ) +import Cardano.Read.Ledger.Eras + ( Era (..) + , IsEra (..) + ) import Cardano.Read.Ledger.Tx.Eras ( onTx ) import Cardano.Wallet.Read ( Tx ) -import Cardano.Wallet.Read.Eras - ( Era (..) - , IsEra (..) - ) import Control.Lens ( (^.) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Inputs.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Inputs.hs index c5bf3fc3fc9..05465a634fb 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Inputs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Inputs.hs @@ -28,10 +28,7 @@ import Cardano.Ledger.Core ( bodyTxL , inputsTxBodyL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -42,6 +39,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Integrity.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Integrity.hs index 77951d9c27e..45bd6f4cf49 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Integrity.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Integrity.hs @@ -35,10 +35,7 @@ import Cardano.Ledger.Api import Cardano.Ledger.Core ( bodyTxL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -49,6 +46,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Metadata.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Metadata.hs index c016e1077f8..9503c984ae8 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Metadata.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Metadata.hs @@ -34,10 +34,7 @@ import Cardano.Ledger.Core import Cardano.Ledger.Shelley.TxAuxData ( ShelleyTxAuxData ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -48,6 +45,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Mint.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Mint.hs index 482af6db7bb..c69248a5dc8 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Mint.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Mint.hs @@ -35,10 +35,7 @@ import Cardano.Ledger.Mary.Core import Cardano.Ledger.Mary.Value ( MultiAsset ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -49,6 +46,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Outputs.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Outputs.hs index 8aead2440e5..f87a8e3074b 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Outputs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Outputs.hs @@ -34,10 +34,7 @@ import Cardano.Ledger.Core import Cardano.Ledger.Shelley.TxOut ( ShelleyTxOut ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -48,6 +45,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/ReferenceInputs.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/ReferenceInputs.hs index c2d84dc29e0..7cdf1e0bed3 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/ReferenceInputs.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/ReferenceInputs.hs @@ -32,10 +32,7 @@ import Cardano.Ledger.Babbage.TxBody import Cardano.Ledger.Core ( bodyTxL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -46,6 +43,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/ScriptValidity.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/ScriptValidity.hs index 7be24e70fba..7c4d0a1d6f4 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/ScriptValidity.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/ScriptValidity.hs @@ -26,10 +26,7 @@ import Cardano.Ledger.Alonzo.Tx ( IsValid , isValidTxL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -40,6 +37,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/TxId.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/TxId.hs index be8091f654d..1d4a583cd6b 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/TxId.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/TxId.hs @@ -27,13 +27,7 @@ import Cardano.Ledger.Core ( bodyTxL , txIdTxBody ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read - ( Tx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -44,6 +38,12 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) +import Cardano.Wallet.Read + ( Tx + ) import Control.Lens ( (^.) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Validity.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Validity.hs index 961f02fbcf4..57181d5c085 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Validity.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Validity.hs @@ -38,10 +38,7 @@ import Cardano.Ledger.Shelley.TxBody import Cardano.Ledger.Slot ( SlotNo ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -52,6 +49,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Withdrawals.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Withdrawals.hs index 74c1241a3d7..de84fd4d68a 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Withdrawals.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Withdrawals.hs @@ -38,10 +38,7 @@ import Cardano.Ledger.Core ( bodyTxL , withdrawalsTxBodyL ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -52,6 +49,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Tx/Witnesses.hs b/lib/read/lib/Cardano/Read/Ledger/Tx/Witnesses.hs index e108baeec1d..41484564987 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Tx/Witnesses.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Tx/Witnesses.hs @@ -31,10 +31,7 @@ import Cardano.Ledger.Core import Cardano.Ledger.Shelley.TxWits ( ShelleyTxWits ) -import Cardano.Read.Ledger.Tx.Eras - ( onTx - ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -45,6 +42,9 @@ import Cardano.Wallet.Read.Eras , Mary , Shelley ) +import Cardano.Read.Ledger.Tx.Eras + ( onTx + ) import Cardano.Wallet.Read.Tx ( Tx (..) ) diff --git a/lib/read/lib/Cardano/Read/Ledger/Value.hs b/lib/read/lib/Cardano/Read/Ledger/Value.hs index e32588e116b..0e38eca617d 100644 --- a/lib/read/lib/Cardano/Read/Ledger/Value.hs +++ b/lib/read/lib/Cardano/Read/Ledger/Value.hs @@ -23,7 +23,7 @@ import Prelude import Cardano.Ledger.Api ( StandardCrypto ) -import Cardano.Wallet.Read.Eras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage diff --git a/lib/read/lib/Cardano/Wallet/Read/Eras.hs b/lib/read/lib/Cardano/Wallet/Read/Eras.hs index cf4bb8215ea..dfd5b5f38dc 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Eras.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Eras.hs @@ -39,18 +39,7 @@ module Cardano.Wallet.Read.Eras ) where -import Cardano.Wallet.Read.Eras.EraFun - ( applyEraFun - , applyEraFunValue - ) -import Cardano.Wallet.Read.Eras.EraValue - ( EraValue (..) - , eraValue - , eraValueSerialize - , extractEraValue - , sequenceEraValue - ) -import Cardano.Wallet.Read.Eras.KnownEras +import Cardano.Read.Ledger.Eras ( Allegra , Alonzo , Babbage @@ -63,6 +52,17 @@ import Cardano.Wallet.Read.Eras.KnownEras , Shelley , knownEraIndices ) +import Cardano.Wallet.Read.Eras.EraFun + ( applyEraFun + , applyEraFunValue + ) +import Cardano.Wallet.Read.Eras.EraValue + ( EraValue (..) + , eraValue + , eraValueSerialize + , extractEraValue + , sequenceEraValue + ) import Generics.SOP ( K (..) , unComp diff --git a/lib/read/lib/Cardano/Wallet/Read/Eras/EraFun.hs b/lib/read/lib/Cardano/Wallet/Read/Eras/EraFun.hs index cf55951f664..6e013a59140 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Eras/EraFun.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Eras/EraFun.hs @@ -28,12 +28,12 @@ module Cardano.Wallet.Read.Eras.EraFun ) where +import Cardano.Read.Ledger.Eras.KnownEras + ( IsEra (..) + ) import Cardano.Wallet.Read.Eras.EraValue ( EraValue (..) ) -import Cardano.Wallet.Read.Eras.KnownEras - ( IsEra (..) - ) import Prelude hiding ( id , (.) diff --git a/lib/read/lib/Cardano/Wallet/Read/Eras/EraValue.hs b/lib/read/lib/Cardano/Wallet/Read/Eras/EraValue.hs index 2f43839b200..95b54dec98f 100644 --- a/lib/read/lib/Cardano/Wallet/Read/Eras/EraValue.hs +++ b/lib/read/lib/Cardano/Wallet/Read/Eras/EraValue.hs @@ -25,7 +25,7 @@ where import Prelude -import Cardano.Wallet.Read.Eras.KnownEras +import Cardano.Read.Ledger.Eras.KnownEras ( Allegra , Alonzo , Babbage diff --git a/lib/read/lib/Cardano/Wallet/Read/Eras/KnownEras.hs b/lib/read/lib/Cardano/Wallet/Read/Eras/KnownEras.hs deleted file mode 100644 index 71ea64cc498..00000000000 --- a/lib/read/lib/Cardano/Wallet/Read/Eras/KnownEras.hs +++ /dev/null @@ -1,79 +0,0 @@ -{-# LANGUAGE DataKinds #-} -{-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE GADTs #-} -{-# LANGUAGE Rank2Types #-} -{-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeFamilies #-} - --- | --- Copyright: © 2020-2022 IOHK --- License: Apache-2.0 --- --- A type list of known eras, useful for indexed-by-era operations. - -module Cardano.Wallet.Read.Eras.KnownEras - ( KnownEras - , knownEraIndices - , Era (..) - , IsEra (..) - , Allegra - , Alonzo - , Babbage - , Byron - , Conway - , Mary - , Shelley - ) where - -import Prelude - -import Cardano.Ledger.Api - ( Allegra - , Alonzo - , Babbage - , ByronEra - , Conway - , Mary - , Shelley - , StandardCrypto - ) -import Generics.SOP - ( Proxy (..) - , lengthSList - ) - -type Byron = ByronEra StandardCrypto - --- | Singleton type for eras. --- --- This GADT provides a value-level representation of eras. -data Era era where - Byron :: Era Byron - Shelley :: Era Shelley - Allegra :: Era Allegra - Mary :: Era Mary - Alonzo :: Era Alonzo - Babbage :: Era Babbage - Conway :: Era Conway - -deriving instance Show (Era era) - --- | Singleton class for eras. -class IsEra era where - theEra :: Era era - -instance IsEra Byron where theEra = Byron -instance IsEra Shelley where theEra = Shelley -instance IsEra Allegra where theEra = Allegra -instance IsEra Mary where theEra = Mary -instance IsEra Alonzo where theEra = Alonzo -instance IsEra Babbage where theEra = Babbage -instance IsEra Conway where theEra = Conway - --- | Type-level list of known eras. -type KnownEras = - '[Byron, Shelley, Allegra, Mary, Alonzo, Babbage, Conway] - --- | Official numbering of the KnownEras. -knownEraIndices :: [Int] -knownEraIndices = [0 .. lengthSList (Proxy :: Proxy KnownEras) - 1]