From 18d5c5c29c60b81942a4f069d82d5534dcae66bb Mon Sep 17 00:00:00 2001 From: Jonathan Knowles Date: Thu, 3 Nov 2022 08:25:17 +0000 Subject: [PATCH] Move type `PreSelection` to `Cardano.Wallet.Transaction`. This helper type is only used by the `constructTransaction` and `mkUnsignedTx` functions, and not used by anything within the `CoinSelection` module hierarchy. --- .../Cardano/Wallet/Api/Http/Shelley/Server.hs | 7 ++---- lib/wallet/src/Cardano/Wallet.hs | 4 +-- .../src/Cardano/Wallet/CoinSelection.hs | 22 ---------------- .../src/Cardano/Wallet/Shelley/Transaction.hs | 4 +-- lib/wallet/src/Cardano/Wallet/Transaction.hs | 25 +++++++++++++++++-- 5 files changed, 29 insertions(+), 33 deletions(-) diff --git a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs index e552f10e175..ac23372a3b2 100644 --- a/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs +++ b/lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs @@ -331,11 +331,7 @@ import Cardano.Wallet.Api.Types.SchemaMetadata import Cardano.Wallet.Api.Types.Transaction ( ApiValidityIntervalExplicit (..), mkApiWitnessCount ) import Cardano.Wallet.CoinSelection - ( PreSelection (..) - , SelectionOf (..) - , SelectionStrategy (..) - , selectionDelta - ) + ( SelectionOf (..), SelectionStrategy (..), selectionDelta ) import Cardano.Wallet.Compat ( (^?) ) import Cardano.Wallet.DB @@ -501,6 +497,7 @@ import Cardano.Wallet.TokenMetadata ( TokenMetadataClient, fillMetadata ) import Cardano.Wallet.Transaction ( DelegationAction (..) + , PreSelection (..) , TransactionCtx (..) , TransactionLayer (..) , Withdrawal (..) diff --git a/lib/wallet/src/Cardano/Wallet.hs b/lib/wallet/src/Cardano/Wallet.hs index 70bf8c854bd..553095c3f72 100644 --- a/lib/wallet/src/Cardano/Wallet.hs +++ b/lib/wallet/src/Cardano/Wallet.hs @@ -240,8 +240,7 @@ import Cardano.Wallet.Checkpoints , sparseCheckpoints ) import Cardano.Wallet.CoinSelection - ( PreSelection - , Selection + ( Selection , SelectionBalanceError (..) , SelectionCollateralRequirement (..) , SelectionConstraints (..) @@ -469,6 +468,7 @@ import Cardano.Wallet.Transaction , ErrMoreSurplusNeeded (ErrMoreSurplusNeeded) , ErrSignTx (..) , ErrUpdateSealedTx (..) + , PreSelection , TransactionCtx (..) , TransactionLayer (..) , TxFeeAndChange (TxFeeAndChange) diff --git a/lib/wallet/src/Cardano/Wallet/CoinSelection.hs b/lib/wallet/src/Cardano/Wallet/CoinSelection.hs index 7b9f759b4f5..38510a51a98 100644 --- a/lib/wallet/src/Cardano/Wallet/CoinSelection.hs +++ b/lib/wallet/src/Cardano/Wallet/CoinSelection.hs @@ -50,7 +50,6 @@ module Cardano.Wallet.CoinSelection , SelectionOf (..) , SelectionParams (..) , SelectionStrategy (..) - , PreSelection (..) -- * Selection skeletons , SelectionSkeleton (..) @@ -385,27 +384,6 @@ toExternalSelectionSkeleton Internal.SelectionSkeleton {..} = -- Selections -------------------------------------------------------------------------------- --- | Represents a unbalanced selection. --- -data PreSelection = PreSelection - { outputs - :: ![TxOut] - -- ^ User-specified outputs - , assetsToMint - :: !TokenMap - -- ^ Assets to mint. - , assetsToBurn - :: !TokenMap - -- ^ Assets to burn. - , extraCoinSource - :: !Coin - -- ^ An extra source of ada. - , extraCoinSink - :: !Coin - -- ^ An extra sink for ada. - } - deriving (Generic, Eq, Show) - -- | Represents a balanced selection. -- data SelectionOf change = Selection diff --git a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs index 9398bd5bcfa..ee717a47bcd 100644 --- a/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs @@ -97,8 +97,7 @@ import Cardano.Slotting.EpochInfo import Cardano.Slotting.EpochInfo.API ( hoistEpochInfo ) import Cardano.Wallet.CoinSelection - ( PreSelection (..) - , SelectionLimitOf (..) + ( SelectionLimitOf (..) , SelectionOf (..) , SelectionSkeleton (..) , selectionDelta @@ -191,6 +190,7 @@ import Cardano.Wallet.Transaction , ErrMkTransaction (..) , ErrMoreSurplusNeeded (ErrMoreSurplusNeeded) , ErrUpdateSealedTx (..) + , PreSelection (..) , TokenMapWithScripts , TransactionCtx (..) , TransactionLayer (..) diff --git a/lib/wallet/src/Cardano/Wallet/Transaction.hs b/lib/wallet/src/Cardano/Wallet/Transaction.hs index 8363c6df4c0..dd97ea7cd8e 100644 --- a/lib/wallet/src/Cardano/Wallet/Transaction.hs +++ b/lib/wallet/src/Cardano/Wallet/Transaction.hs @@ -25,6 +25,7 @@ module Cardano.Wallet.Transaction TransactionLayer (..) , DelegationAction (..) , TransactionCtx (..) + , PreSelection (..) , defaultTransactionCtx , Withdrawal (..) , withdrawalToCoin @@ -68,8 +69,7 @@ import Cardano.Ledger.Crypto import Cardano.Pool.Types ( PoolId ) import Cardano.Wallet.CoinSelection - ( PreSelection - , SelectionCollateralRequirement (..) + ( SelectionCollateralRequirement (..) , SelectionLimit , SelectionOf (..) , SelectionSkeleton @@ -390,6 +390,27 @@ data TransactionCtx = TransactionCtx -- this. For instance: datums. } deriving (Show, Generic, Eq) +-- | Represents a unbalanced selection. +-- +data PreSelection = PreSelection + { outputs + :: ![TxOut] + -- ^ User-specified outputs + , assetsToMint + :: !TokenMap + -- ^ Assets to mint. + , assetsToBurn + :: !TokenMap + -- ^ Assets to burn. + , extraCoinSource + :: !Coin + -- ^ An extra source of ada. + , extraCoinSink + :: !Coin + -- ^ An extra sink for ada. + } + deriving (Generic, Eq, Show) + data Withdrawal = WithdrawalSelf RewardAccount (NonEmpty DerivationIndex) Coin | WithdrawalExternal RewardAccount (NonEmpty DerivationIndex) Coin