Skip to content

Commit

Permalink
[ADP-3229] Move primitive read and conversions into primitive (#4260)
Browse files Browse the repository at this point in the history
- [x] move Read.Primitive wallet hierarchy into primitive as needed by
network-layer lib
- [x] rename Read.Primitive namespace in Primitive.Ledger.Read
- [x] move Primitive.Convert module in Primitive.Ledger namespace

ADP-3229
  • Loading branch information
paolino authored Nov 24, 2023
2 parents 16272f3 + c43fe21 commit fa821b9
Show file tree
Hide file tree
Showing 67 changed files with 1,133 additions and 860 deletions.
2 changes: 1 addition & 1 deletion lib/balance-tx/lib/internal/Internal/Cardano/Write/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ import qualified Cardano.Ledger.Keys as Ledger
import qualified Cardano.Ledger.Shelley.API.Wallet as Shelley
import qualified Cardano.Ledger.Shelley.UTxO as Shelley
import qualified Cardano.Ledger.TxIn as Ledger
import qualified Cardano.Wallet.Primitive.Convert as Convert
import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert
import qualified Cardano.Wallet.Primitive.Types.Tx.Constraints as W
( txOutMaxCoin
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ import qualified Cardano.Api.Shelley as CardanoApi
import qualified Cardano.CoinSelection.UTxOIndex as UTxOIndex
import qualified Cardano.CoinSelection.UTxOSelection as UTxOSelection
import qualified Cardano.Ledger.Core as Core
import qualified Cardano.Wallet.Primitive.Convert as Convert
import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert
import qualified Cardano.Wallet.Primitive.Types.Address as W
( Address
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import Internal.Cardano.Write.Tx
, Version
)

import qualified Cardano.Wallet.Primitive.Convert as Convert
import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert
import qualified Cardano.Wallet.Primitive.Types.TokenBundle as W
( TokenBundle
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ import qualified Cardano.Api.Byron as CardanoApi
import qualified Cardano.Api.Shelley as CardanoApi
import qualified Cardano.Ledger.Alonzo.Scripts as Alonzo
import qualified Cardano.Ledger.Api as Ledger
import qualified Cardano.Wallet.Primitive.Convert as Convert
import qualified Cardano.Wallet.Primitive.Ledger.Convert as Convert
import qualified Cardano.Wallet.Primitive.Types.Coin as W
( Coin (..)
)
Expand Down
45 changes: 40 additions & 5 deletions lib/primitive/cardano-wallet-primitive.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,18 @@ library
, cardano-binary
, cardano-crypto
, cardano-crypto-class
, cardano-crypto-wrapper
, cardano-ledger-allegra
, cardano-ledger-alonzo
, cardano-ledger-api
, cardano-ledger-babbage
, cardano-ledger-byron
, cardano-ledger-conway
, cardano-ledger-core
, cardano-ledger-mary
, cardano-ledger-shelley
, cardano-numeric
, cardano-protocol-tpraos
, cardano-slotting
, cardano-strict-containers
, cardano-wallet-read
Expand Down Expand Up @@ -87,6 +92,7 @@ library
, OddWord
, ouroboros-consensus
, ouroboros-consensus-cardano
, ouroboros-network-api
, pretty-simple
, QuickCheck
, quiet
Expand All @@ -104,27 +110,28 @@ library
exposed-modules:
Cardano.Wallet.Orphans
Cardano.Wallet.Primitive.Collateral
Cardano.Wallet.Primitive.Convert
Cardano.Wallet.Primitive.Ledger.Convert
Cardano.Wallet.Primitive.NetworkId
Cardano.Wallet.Primitive.Slotting
Cardano.Wallet.Primitive.Slotting.Legacy
Cardano.Wallet.Primitive.SyncProgress
Cardano.Wallet.Primitive.Types.Address
Cardano.Wallet.Primitive.Types.Address.Gen
Cardano.Wallet.Primitive.Types.AnyExplicitScripts
Cardano.Wallet.Primitive.Types.Block
Cardano.Wallet.Primitive.Types.Block.Gen
Cardano.Wallet.Primitive.Types.BlockSummary
Cardano.Wallet.Primitive.Types.Certificates
Cardano.Wallet.Primitive.Types.Checkpoints.Policy
Cardano.Wallet.Primitive.Types.Coin
Cardano.Wallet.Primitive.Types.Coin.Gen
Cardano.Wallet.Primitive.Types.DecentralizationLevel
Cardano.Wallet.Primitive.Types.DelegationCertificate
Cardano.Wallet.Primitive.Types.EpochNo
Cardano.Wallet.Primitive.Types.EraInfo
Cardano.Wallet.Primitive.Types.ExecutionUnitPrices
Cardano.Wallet.Primitive.Types.FeePolicy
Cardano.Wallet.Primitive.Types.Hash
Cardano.Wallet.Primitive.Types.PoolId
Cardano.Wallet.Primitive.Types.Pool
Cardano.Wallet.Primitive.Types.ProtocolMagic
Cardano.Wallet.Primitive.Types.ProtocolParameters
Cardano.Wallet.Primitive.Types.Range
Expand All @@ -133,12 +140,14 @@ library
Cardano.Wallet.Primitive.Types.SlotId
Cardano.Wallet.Primitive.Types.SlottingParameters
Cardano.Wallet.Primitive.Types.SlottingParameters.Gen
Cardano.Wallet.Primitive.Types.StakePoolMetadata
Cardano.Wallet.Primitive.Types.StakePoolSummary
Cardano.Wallet.Primitive.Types.TokenBundle
Cardano.Wallet.Primitive.Types.TokenBundle.Gen
Cardano.Wallet.Primitive.Types.TokenBundleMaxSize
Cardano.Wallet.Primitive.Types.TokenMap
Cardano.Wallet.Primitive.Types.TokenMap.Gen
Cardano.Wallet.Primitive.Types.TokenMapWithScripts
Cardano.Wallet.Primitive.Types.TokenPolicy
Cardano.Wallet.Primitive.Types.TokenPolicy.Gen
Cardano.Wallet.Primitive.Types.TokenQuantity
Expand All @@ -156,6 +165,32 @@ library
Cardano.Wallet.Primitive.Types.TxParameters
Cardano.Wallet.Primitive.Types.UTxO
Cardano.Wallet.Primitive.Types.UTxO.Gen
Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit
Cardano.Wallet.Primitive.Types.WitnessCount
Cardano.Wallet.Primitive.Ledger.Read.Block
Cardano.Wallet.Primitive.Ledger.Read.Block.Header
Cardano.Wallet.Primitive.Ledger.Read.Tx
Cardano.Wallet.Primitive.Ledger.Read.Tx.Allegra
Cardano.Wallet.Primitive.Ledger.Read.Tx.Alonzo
Cardano.Wallet.Primitive.Ledger.Read.Tx.Babbage
Cardano.Wallet.Primitive.Ledger.Read.Tx.Byron
Cardano.Wallet.Primitive.Ledger.Read.Tx.Conway
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralInputs
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.CollateralOutputs
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ExtraSigs
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Fee
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Inputs
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Integrity
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Metadata
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Mint
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Outputs
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.ScriptValidity
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Validity
Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Withdrawals
Cardano.Wallet.Primitive.Ledger.Read.Tx.Mary
Cardano.Wallet.Primitive.Ledger.Read.Tx.Sealed
Cardano.Wallet.Primitive.Ledger.Read.Tx.Shelley
Cardano.Wallet.Unsafe
Cardano.Wallet.Util
Control.Monad.Random.NonRandom
Expand Down Expand Up @@ -217,14 +252,14 @@ test-suite test
build-tool-depends: hspec-discover:hspec-discover
other-modules:
Cardano.Wallet.Primitive.CollateralSpec
Cardano.Wallet.Primitive.ConvertSpec
Cardano.Wallet.Primitive.Ledger.ConvertSpec
Cardano.Wallet.Primitive.SlottingSpec
Cardano.Wallet.Primitive.SyncProgressSpec
Cardano.Wallet.Primitive.Types.AddressSpec
Cardano.Wallet.Primitive.Types.BlockSummarySpec
Cardano.Wallet.Primitive.Types.CoinSpec
Cardano.Wallet.Primitive.Types.HashSpec
Cardano.Wallet.Primitive.Types.PoolIdSpec
Cardano.Wallet.Primitive.Types.PoolSpec
Cardano.Wallet.Primitive.Types.RangeSpec
Cardano.Wallet.Primitive.Types.TokenBundleSpec
Cardano.Wallet.Primitive.Types.TokenMapSpec
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
-- Exposes a wallet-friendly interface to types and functions exported by the
-- ledger specification.
--
module Cardano.Wallet.Primitive.Convert
module Cardano.Wallet.Primitive.Ledger.Convert
(
-- * Conversions from wallet types to ledger specification types
toLedgerAddress
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{-# LANGUAGE ApplicativeDo #-}
{-# LANGUAGE DataKinds #-}

module Cardano.Wallet.Read.Primitive.Block
module Cardano.Wallet.Primitive.Ledger.Read.Block
( primitiveBlock
, fromCardanoBlock
)
Expand All @@ -12,6 +12,15 @@ import Prelude hiding
, (.)
)

import Cardano.Wallet.Primitive.Ledger.Read.Block.Header
( primitiveBlockHeader
)
import Cardano.Wallet.Primitive.Ledger.Read.Tx
( primitiveTx
)
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Features.Certificates
( primitiveCertificates
)
import Cardano.Wallet.Read
( Block
, ConsensusBlock
Expand All @@ -35,15 +44,6 @@ import Cardano.Wallet.Read.Eras.EraFun
, (*&&&*)
, (*****)
)
import Cardano.Wallet.Read.Primitive.Block.Header
( primitiveBlockHeader
)
import Cardano.Wallet.Read.Primitive.Tx
( primitiveTx
)
import Cardano.Wallet.Read.Primitive.Tx.Features.Certificates
( primitiveCertificates
)
import Cardano.Wallet.Read.Tx.Certificates
( getEraCertificates
)
Expand All @@ -54,7 +54,8 @@ import Control.Error
( partitionEithers
)

import qualified Cardano.Wallet.Primitive.Types as W
import qualified Cardano.Wallet.Primitive.Types.Block as W
import qualified Cardano.Wallet.Primitive.Types.Certificates as W
import qualified Cardano.Wallet.Primitive.Types.Hash as W
import qualified Cardano.Wallet.Primitive.Types.Tx as W

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.Wallet.Read.Primitive.Block.Header
module Cardano.Wallet.Primitive.Ledger.Read.Block.Header
( getBlockHeader
, primitiveBlockHeader
)
Expand Down Expand Up @@ -70,7 +70,7 @@ import Ouroboros.Consensus.Shelley.Protocol.Abstract

import qualified Cardano.Crypto.Hashing as CC
import qualified Cardano.Protocol.TPraos.BHeader as SL
import qualified Cardano.Wallet.Primitive.Types as W
import qualified Cardano.Wallet.Primitive.Types.Block as W
import qualified Cardano.Wallet.Primitive.Types.Hash as W
import qualified Ouroboros.Network.Block as O

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,58 @@
-- |
-- Copyright: © 2020 IOHK
-- License: Apache-2.0
module Cardano.Wallet.Read.Primitive.Tx (
module Cardano.Wallet.Primitive.Ledger.Read.Tx (
fromCardanoTx,
primitiveTx,
) where

import Prelude

import Cardano.Wallet.Read
( Tx (..)
)
import Cardano.Wallet.Read.Eras
( EraFun (..)
)
import Cardano.Wallet.Read.Primitive.Tx.Allegra
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Allegra
( fromAllegraTx
, fromAllegraTx'
)
import Cardano.Wallet.Read.Primitive.Tx.Alonzo
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Alonzo
( fromAlonzoTx
, fromAlonzoTx'
)
import Cardano.Wallet.Read.Primitive.Tx.Babbage
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Babbage
( fromBabbageTx
, fromBabbageTx'
)
import Cardano.Wallet.Read.Primitive.Tx.Byron
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Byron
( fromTxAux
)
import Cardano.Wallet.Read.Primitive.Tx.Conway
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Conway
( fromConwayTx
, fromConwayTx'
)
import Cardano.Wallet.Read.Primitive.Tx.Mary
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Mary
( fromMaryTx
, fromMaryTx'
)
import Cardano.Wallet.Read.Primitive.Tx.Shelley
import Cardano.Wallet.Primitive.Ledger.Read.Tx.Shelley
( fromShelleyTx
, fromShelleyTx'
)
import Cardano.Wallet.Transaction
( TokenMapWithScripts (..)
, ValidityIntervalExplicit (..)
, WitnessCount
, WitnessCountCtx
import Cardano.Wallet.Primitive.Types.TokenMapWithScripts
( TokenMapWithScripts
, emptyTokenMapWithScripts
)
import Cardano.Wallet.Primitive.Types.ValidityIntervalExplicit
( ValidityIntervalExplicit
)
import Cardano.Wallet.Primitive.Types.WitnessCount
( WitnessCount
, WitnessCountCtx
, emptyWitnessCount
)
import Cardano.Wallet.Read
( Tx (..)
)
import Cardano.Wallet.Read.Eras
( EraFun (..)
)
import Generics.SOP
( K (..)
)
Expand All @@ -61,7 +65,7 @@ import qualified Cardano.Api.Byron as Cardano
( Tx (ByronTx)
)
import qualified Cardano.Api.Shelley as Cardano
import qualified Cardano.Wallet.Primitive.Types as W
import qualified Cardano.Wallet.Primitive.Types.Certificates as W
import qualified Cardano.Wallet.Primitive.Types.Tx as W

fromCardanoTx ::
Expand Down
Loading

0 comments on commit fa821b9

Please sign in to comment.