Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterize UTxO identifier type in internal coin selection modules. #3157

Conversation

jonathanknowles
Copy link
Member

@jonathanknowles jonathanknowles commented Feb 25, 2022

Issue Number

ADP-1478

Summary

This PR parameterizes the UTxO identifier type in all modules within the CoinSelection.Internal hierarchy.

As before, we use the type parameter u to represent the type of unique identifiers for individual UTxOs (unspent transaction outputs).

In general, callers of coin selection can instantiate u to any type for which there is an Ord instance.

Not tackled by this PR

A future PR will update the test suite to use a more general type of UTxO identifier. For now, we continue to generate arbitrary values of (TxIn, Address) to act as UTxO identifiers.

Before this change, `outputs` was always instantiated in one of two ways:

    - outputs ~ [        (Address, TokenBundle)]
    - outputs ~ NonEmpty (Address, TokenBundle)

In both cases, the type of an individual output is `(Address, TokenBundle)`.
The only difference between these instantiations is the container type.

As a result of this change, the above instantiations are simplified to:

    - outputs ~ []
    - outputs ~ NonEmpty

This allows us to simplify the type signatures of many functions that
use the `SelectionParamsOf` and `SelectionResultOf` types, because we
now only need to specify the container type, and not the type of output.
As before, we use the `u` parameter to represent the type of unique UTxO
identifiers (unique identifiers for individual unspent transaction outputs).
As before, we use the `u` parameter to represent the type of unique UTxO
identifiers (unique identifiers for individual unspent transaction outputs).
As before, we use the `u` parameter to represent the type of unique UTxO
identifiers (unique identifiers for individual unspent transaction outputs).
…ernal`.

As before, we use the `u` parameter to represent the type of unique UTxO
identifiers (unique identifiers for individual unspent transaction outputs).
@jonathanknowles jonathanknowles self-assigned this Feb 25, 2022
@jonathanknowles jonathanknowles marked this pull request as ready for review February 25, 2022 09:39
@jonathanknowles jonathanknowles force-pushed the jonathanknowles/use-type-parameter-for-utxo-identifier-in-internal-coin-selection-modules branch from a693587 to 7120457 Compare February 25, 2022 09:42
This fixes a slight inconsistency in the API, making `availableMap`
consistent with `leftoverMap` and `selectedMap`.
{ outputsToCover
:: !outputs
:: !(outputs (Address, TokenBundle))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

@Anviking
Copy link
Member

bors r+

iohk-bors bot added a commit that referenced this pull request Feb 25, 2022
3157: Parameterize UTxO identifier type in internal coin selection modules. r=Anviking a=jonathanknowles

## Issue Number

ADP-1478

## Summary

This PR parameterizes the UTxO identifier type in all modules within the `CoinSelection.Internal` hierarchy.

As before, we use the type parameter `u` to represent the type of unique identifiers for individual UTxOs (unspent transaction outputs).

In general, callers of coin selection can instantiate `u` to any type for which there is an `Ord` instance.

## Not tackled by this PR

A future PR will update the test suite to use a more general type of UTxO identifier. For now, we continue to generate arbitrary values of `(TxIn, Address)` to act as UTxO identifiers.

Co-authored-by: Jonathan Knowles <[email protected]>
@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 25, 2022

Build failed:

  src/Test/Integration/Scenario/API/Shelley/Wallets.hs:558:9: 
  1) API Specifications, SHELLEY_WALLETS, WALLETS_GET_02, WALLETS_DELETE_01 - Deleted wallet is not available
       From the following response: Left
           ( DecodeFailure "Something went wrong" "Error in $: Failed reading: not a valid json value at 'Somethingwentwrong'" )
       expected: Status {statusCode = 404, statusMessage = "Not Found"}
        but got: Status {statusCode = 500, statusMessage = "Internal Server Error"}

@Anviking
Copy link
Member

bors r+

@iohk-bors
Copy link
Contributor

iohk-bors bot commented Feb 25, 2022

Build succeeded:

@iohk-bors iohk-bors bot merged commit cc0f201 into master Feb 25, 2022
@iohk-bors iohk-bors bot deleted the jonathanknowles/use-type-parameter-for-utxo-identifier-in-internal-coin-selection-modules branch February 25, 2022 19:22
WilliamKingNoel-Bot pushed a commit that referenced this pull request Feb 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants