Skip to content

Commit

Permalink
[ADP-3215] Clean up imports in read (#4716)
Browse files Browse the repository at this point in the history
This pull request cleans up a few imports involving the `read` package.
This is a pure refactoring — in fact, it's a pure rearranging of
imports.

### Comment

* Despite being a no-op on the functionality, this pull request is
important for internal structure. The idea is that we import an
identifier, such as `IsEra`, from the highest level of abstraction that
exports it. For instance, instead of importing `IsEra` from
`Cardano.Wallet.Read.Eras.KnownEras`, we import it from the higher
module `Cardano.Wallet.Read.Eras`. Following this scheme ensures that
the highest module `Cardano.Wallet.Read.Eras` can act as an abstraction
boundary, as we can now rearrange children of this module without
affecting independent modules. In turn, a single qualified import of
`Cardano.Wallet.Read.Eras` can now bring the entire abstraction into
scope.

### Issue Number

ADP-3215
  • Loading branch information
HeinrichApfelmus authored Aug 5, 2024
2 parents 8fb09f4 + 7774faa commit 3d9981d
Show file tree
Hide file tree
Showing 41 changed files with 84 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ import Cardano.Wallet.Read
)
import Cardano.Wallet.Read.Eras
( K (..)
, applyEraFun
, (:*:) (..)
)
import Cardano.Wallet.Read.Eras.EraFun
( applyEraFun
)
import Cardano.Wallet.Transaction
( TokenMapWithScripts
, ValidityIntervalExplicit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ module Cardano.Wallet.Primitive.Ledger.Read.Block.Header
)
where

import Prelude hiding
( (.)
)
import Prelude

import Cardano.Crypto.Hash.Class
( hashToBytes
Expand Down Expand Up @@ -52,9 +50,6 @@ import Cardano.Wallet.Read
import Cardano.Wallet.Read.Eras.EraFun
( applyEraFun
)
import Control.Category
( (.)
)
import Data.Coerce
( coerce
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates
)
where

import Prelude hiding
( (.)
)
import Prelude

import Cardano.Crypto.Hash.Class
( hashToBytes
Expand Down Expand Up @@ -71,9 +69,6 @@ import Cardano.Wallet.Read.Eras
import Cardano.Wallet.Util
( internalError
)
import Control.Category
( (.)
)
import Data.Foldable
( toList
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ module Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Integrity

where

import Prelude hiding
( (.)
)
import Prelude

import Cardano.Ledger.Alonzo.Tx
( ScriptIntegrityHash
Expand All @@ -42,9 +40,6 @@ import Cardano.Wallet.Read.Eras
import Cardano.Wallet.Read.Tx
( Tx
)
import Control.Category
( (.)
)
import Data.Maybe.Strict
( StrictMaybe
, strictMaybeToMaybe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@ import Cardano.Read.Ledger.Tx.Cardano
import Cardano.Wallet.Primitive.Types.Tx.SealedTx
( SealedTx (unsafeCardanoTx)
)
import Cardano.Wallet.Read.Eras
import Cardano.Wallet.Read
( EraValue
, Tx
, applyEraFun
)
import Cardano.Wallet.Read.Tx
( Tx (..)
)

import qualified Cardano.Wallet.Primitive.Types.Tx.SealedTx as W

Expand Down
6 changes: 2 additions & 4 deletions lib/read/lib/Cardano/Read/Ledger/Block/BHeader.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ import Cardano.Wallet.Read.Eras
, Babbage
, Byron
, Conway
, Era (..)
, IsEra (..)
, Mary
, Shelley
)
import Cardano.Wallet.Read.Eras.KnownEras
( Era (..)
, IsEra (..)
)
import GHC.Generics
( Generic
)
Expand Down
7 changes: 2 additions & 5 deletions lib/read/lib/Cardano/Read/Ledger/Block/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,13 @@ import Cardano.Wallet.Read.Eras
, Babbage
, Byron
, Conway
, Era (..)
, EraValue (..)
, IsEra
, IsEra (..)
, Mary
, Shelley
, eraValue
)
import Cardano.Wallet.Read.Eras.KnownEras
( Era (..)
, IsEra (..)
)
import Ouroboros.Consensus.Protocol.Praos
( Praos
)
Expand Down
13 changes: 5 additions & 8 deletions lib/read/lib/Cardano/Read/Ledger/Block/HeaderHash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ where

import Prelude

import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Binary
( EncCBOR
, EncCBORGroup
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Ledger.Era
( EraSegWits (..)
)
Expand All @@ -49,14 +49,11 @@ import Cardano.Wallet.Read.Eras
, Babbage
, Byron
, Conway
, IsEra
, Era (..)
, IsEra (..)
, Mary
, Shelley
)
import Cardano.Wallet.Read.Eras.KnownEras
( Era (..)
, IsEra (..)
)
import Cardano.Wallet.Read.Hash
( Blake2b_256
, Hash
Expand Down
2 changes: 1 addition & 1 deletion lib/read/lib/Cardano/Read/Ledger/Block/SlotNo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import Prelude
import Cardano.Read.Ledger.Block.BHeader
( BHeader (..)
)
import Cardano.Wallet.Read.Eras.KnownEras
import Cardano.Wallet.Read.Eras
( Era (..)
, IsEra (..)
)
Expand Down
4 changes: 1 addition & 3 deletions lib/read/lib/Cardano/Read/Ledger/Block/Txs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ import Cardano.Read.Ledger.Block.Block
)
import Cardano.Wallet.Read.Eras
( Byron
)
import Cardano.Wallet.Read.Eras.KnownEras
( Era (..)
, Era (..)
, IsEra (..)
)
import Cardano.Wallet.Read.Tx
Expand Down
9 changes: 3 additions & 6 deletions lib/read/lib/Cardano/Read/Ledger/Tx/CBOR.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,16 @@ import Cardano.Ledger.Binary.Decoding
, shelleyProtVer
)
import Cardano.Wallet.Read.Eras
( EraValue
, IsEra
( Era (..)
, EraValue
, IsEra (..)
, K (..)
, applyEraFunValue
, extractEraValue
, sequenceEraValue
, unK
, (:.:) (..)
)
import Cardano.Wallet.Read.Eras.KnownEras
( Era (..)
, IsEra (..)
)
import Cardano.Wallet.Read.Tx
( Tx (..)
, TxT
Expand Down
6 changes: 2 additions & 4 deletions lib/read/lib/Cardano/Read/Ledger/Tx/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ module Cardano.Read.Ledger.Tx.Cardano
import Prelude

import Cardano.Wallet.Read.Eras
( EraValue
, eraValue
)
import Cardano.Wallet.Read.Eras.KnownEras
( Allegra
, Alonzo
, Babbage
, Conway
, EraValue
, Mary
, Shelley
, eraValue
)
import Cardano.Wallet.Read.Tx
( Tx (..)
Expand Down
6 changes: 2 additions & 4 deletions lib/read/lib/Cardano/Read/Ledger/Tx/Certificates.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,13 @@ module Cardano.Read.Ledger.Tx.Certificates
import Prelude

import Cardano.Ledger.Api
( bodyTxL
( StandardCrypto
, bodyTxL
, certsTxBodyL
)
import Cardano.Ledger.Conway.TxCert
( ConwayTxCert
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Ledger.Shelley.TxCert
( ShelleyTxCert
)
Expand Down
6 changes: 2 additions & 4 deletions lib/read/lib/Cardano/Read/Ledger/Tx/CollateralInputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,12 @@ module Cardano.Read.Ledger.Tx.CollateralInputs
import Prelude

import Cardano.Ledger.Api
( collateralInputsTxBodyL
( StandardCrypto
, collateralInputsTxBodyL
)
import Cardano.Ledger.Core
( bodyTxL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/CollateralOutputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module Cardano.Read.Ledger.Tx.CollateralOutputs

import Prelude

import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Babbage.Collateral
()
import Cardano.Ledger.Babbage.Rules
Expand All @@ -36,9 +39,6 @@ import Cardano.Ledger.Babbage.TxBody
import Cardano.Ledger.Core
( bodyTxL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/ExtraSigs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ import Prelude
import Cardano.Ledger.Alonzo.TxBody
( reqSignerHashesTxBodyL
)
import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Core
( bodyTxL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Ledger.Keys
( KeyHash
, KeyRole (..)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/Inputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ module Cardano.Read.Ledger.Tx.Inputs

import Prelude

import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Core
( bodyTxL
, inputsTxBodyL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/Integrity.hs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import Cardano.Ledger.Alonzo.Tx
import Cardano.Ledger.Alonzo.TxBody
( scriptIntegrityHashTxBodyL
)
import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Core
( bodyTxL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/Mint.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ module Cardano.Read.Ledger.Tx.Mint

import Prelude

import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Core
( bodyTxL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Ledger.Mary.Core
( mintTxBodyL
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/ReferenceInputs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ module Cardano.Read.Ledger.Tx.ReferenceInputs

import Prelude

import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Babbage.TxBody
( referenceInputsTxBodyL
)
import Cardano.Ledger.Core
( bodyTxL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/TxId.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ import Cardano.Chain.UTxO
import Cardano.Crypto.Hashing
( serializeCborHash
)
import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Core
( bodyTxL
, txIdTxBody
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
6 changes: 3 additions & 3 deletions lib/read/lib/Cardano/Read/Ledger/Tx/Withdrawals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ import Cardano.Ledger.Address
( RewardAccount
, unWithdrawals
)
import Cardano.Ledger.Api
( StandardCrypto
)
import Cardano.Ledger.Coin
( Coin
)
import Cardano.Ledger.Core
( bodyTxL
, withdrawalsTxBodyL
)
import Cardano.Ledger.Crypto
( StandardCrypto
)
import Cardano.Read.Ledger.Tx.Eras
( onTx
)
Expand Down
Loading

0 comments on commit 3d9981d

Please sign in to comment.