-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
3109: Provide a wallet-specific interface for coin selection. r=jonathanknowles a=jonathanknowles ## Issue Number ADP-1407 ## Summary This PR reorganizes the coin selection module hierarchy to have the following structure: - `Cardano.Wallet.CoinSelection` provides a stable, **wallet-specific** interface for coin selection, with wallet-friendly types such as `TxIn`, `TxOut`, and `UTxO`. - `Cardano.Wallet.CoinSelection.Internal.*` provides **internal** functions and types, whose definitions are allowed to deviate from those provided in the public module. This PR also: - adjusts all parts of the wallet that need coin selection functionality to import from `Cardano.Wallet.CoinSelection`, rather than `Cardano.Wallet.CoinSelection.Internal`. - adjusts the names of some error types and constructors to avoid name collisions. Co-authored-by: Jonathan Knowles <[email protected]>
- Loading branch information
Showing
17 changed files
with
267 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
-- | | ||
-- Copyright: © 2022 IOHK | ||
-- License: Apache-2.0 | ||
-- | ||
-- This module provides a wallet-specific interface for coin selection. | ||
-- | ||
-- Coin selection handles the following responsibilities: | ||
-- | ||
-- - selecting inputs from the UTxO set to pay for user-specified outputs; | ||
-- - selecting inputs from the UTxO set to pay for collateral; | ||
-- - producing change outputs to return excess value to the wallet; | ||
-- - balancing a selection to pay for the transaction fee. | ||
-- | ||
-- Use the 'performSelection' function to perform a coin selection. | ||
-- | ||
module Cardano.Wallet.CoinSelection | ||
( | ||
-- * Performing selections | ||
performSelection | ||
, Selection | ||
, SelectionCollateralRequirement (..) | ||
, SelectionConstraints (..) | ||
, SelectionError (..) | ||
, SelectionLimit | ||
, SelectionLimitOf (..) | ||
, SelectionOf (..) | ||
, SelectionParams (..) | ||
|
||
-- * Selection skeletons | ||
, SelectionSkeleton (..) | ||
, emptySkeleton | ||
|
||
-- * Selection errors | ||
, BalanceInsufficientError (..) | ||
, SelectionBalanceError (..) | ||
, SelectionCollateralError | ||
, SelectionOutputError (..) | ||
, SelectionOutputSizeExceedsLimitError (..) | ||
, SelectionOutputTokenQuantityExceedsLimitError (..) | ||
, UnableToConstructChangeError (..) | ||
|
||
-- * Selection reports | ||
, makeSelectionReportDetailed | ||
, makeSelectionReportSummarized | ||
, SelectionReportDetailed | ||
, SelectionReportSummarized | ||
|
||
-- * Selection deltas | ||
, balanceMissing | ||
, selectionDelta | ||
) | ||
where | ||
|
||
import Cardano.Wallet.CoinSelection.Internal | ||
( Selection | ||
, SelectionCollateralRequirement (..) | ||
, SelectionConstraints (..) | ||
, SelectionError (..) | ||
, SelectionOf (..) | ||
, SelectionOutputError (..) | ||
, SelectionOutputSizeExceedsLimitError (..) | ||
, SelectionOutputTokenQuantityExceedsLimitError (..) | ||
, SelectionParams (..) | ||
, SelectionReportDetailed | ||
, SelectionReportSummarized | ||
, makeSelectionReportDetailed | ||
, makeSelectionReportSummarized | ||
, performSelection | ||
, selectionDelta | ||
) | ||
import Cardano.Wallet.CoinSelection.Internal.Balance | ||
( BalanceInsufficientError (..) | ||
, SelectionBalanceError (..) | ||
, SelectionLimit | ||
, SelectionLimitOf (..) | ||
, SelectionSkeleton (..) | ||
, UnableToConstructChangeError (..) | ||
, balanceMissing | ||
, emptySkeleton | ||
) | ||
import Cardano.Wallet.CoinSelection.Internal.Collateral | ||
( SelectionCollateralError ) |
Oops, something went wrong.