Skip to content

Commit

Permalink
Move type PreSelection to Cardano.Wallet.Transaction.
Browse files Browse the repository at this point in the history
This helper type is only used by the `constructTransaction` and
`mkUnsignedTx` functions, and not used by anything within the
`CoinSelection` module hierarchy.
  • Loading branch information
jonathanknowles authored and Unisay committed Nov 10, 2022
1 parent d23c432 commit 18d5c5c
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 33 deletions.
7 changes: 2 additions & 5 deletions lib/wallet/api/http/Cardano/Wallet/Api/Http/Shelley/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -501,6 +497,7 @@ import Cardano.Wallet.TokenMetadata
( TokenMetadataClient, fillMetadata )
import Cardano.Wallet.Transaction
( DelegationAction (..)
, PreSelection (..)
, TransactionCtx (..)
, TransactionLayer (..)
, Withdrawal (..)
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet/src/Cardano/Wallet.hs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ import Cardano.Wallet.Checkpoints
, sparseCheckpoints
)
import Cardano.Wallet.CoinSelection
( PreSelection
, Selection
( Selection
, SelectionBalanceError (..)
, SelectionCollateralRequirement (..)
, SelectionConstraints (..)
Expand Down Expand Up @@ -469,6 +468,7 @@ import Cardano.Wallet.Transaction
, ErrMoreSurplusNeeded (ErrMoreSurplusNeeded)
, ErrSignTx (..)
, ErrUpdateSealedTx (..)
, PreSelection
, TransactionCtx (..)
, TransactionLayer (..)
, TxFeeAndChange (TxFeeAndChange)
Expand Down
22 changes: 0 additions & 22 deletions lib/wallet/src/Cardano/Wallet/CoinSelection.hs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ module Cardano.Wallet.CoinSelection
, SelectionOf (..)
, SelectionParams (..)
, SelectionStrategy (..)
, PreSelection (..)

-- * Selection skeletons
, SelectionSkeleton (..)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/wallet/src/Cardano/Wallet/Shelley/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ import Cardano.Slotting.EpochInfo
import Cardano.Slotting.EpochInfo.API
( hoistEpochInfo )
import Cardano.Wallet.CoinSelection
( PreSelection (..)
, SelectionLimitOf (..)
( SelectionLimitOf (..)
, SelectionOf (..)
, SelectionSkeleton (..)
, selectionDelta
Expand Down Expand Up @@ -191,6 +190,7 @@ import Cardano.Wallet.Transaction
, ErrMkTransaction (..)
, ErrMoreSurplusNeeded (ErrMoreSurplusNeeded)
, ErrUpdateSealedTx (..)
, PreSelection (..)
, TokenMapWithScripts
, TransactionCtx (..)
, TransactionLayer (..)
Expand Down
25 changes: 23 additions & 2 deletions lib/wallet/src/Cardano/Wallet/Transaction.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module Cardano.Wallet.Transaction
TransactionLayer (..)
, DelegationAction (..)
, TransactionCtx (..)
, PreSelection (..)
, defaultTransactionCtx
, Withdrawal (..)
, withdrawalToCoin
Expand Down Expand Up @@ -68,8 +69,7 @@ import Cardano.Ledger.Crypto
import Cardano.Pool.Types
( PoolId )
import Cardano.Wallet.CoinSelection
( PreSelection
, SelectionCollateralRequirement (..)
( SelectionCollateralRequirement (..)
, SelectionLimit
, SelectionOf (..)
, SelectionSkeleton
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 18d5c5c

Please sign in to comment.