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

Modify coin selection algorithm to support minting and burning #2725

Merged
merged 40 commits into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1ce4c75
Modify coin selection to support minting and burning
sevanspowell Jun 16, 2021
3818c7e
Improve language around OutputsInsufficientError
sevanspowell Jun 23, 2021
ff7a2a6
Improve language around 'MintedNotSpent'
sevanspowell Jun 23, 2021
3854bc6
Fix errors in commentary
sevanspowell Jun 23, 2021
4f09d5d
Single line between top-level defns
sevanspowell Jun 23, 2021
9bb91f7
Add commentary to pluralized change map functions
sevanspowell Jun 23, 2021
66edfcb
Add TokenQuantity.difference function
sevanspowell Jun 23, 2021
5093d30
Refactor removeBurnValueFromChangeMaps
sevanspowell Jun 23, 2021
e6d6d27
Simplify TokenMap.difference with new TokenQuantity.difference func
sevanspowell Jun 23, 2021
ecde5a9
Further refactor "removeBurnValueFromChangeMaps"
sevanspowell Jun 23, 2021
52503e6
Styling
sevanspowell Jun 23, 2021
5ed7da6
Fix formatting on 'removeBurnValuesFromChangeMaps'
sevanspowell Jun 23, 2021
e646a26
Fix indentation, use monoid operator
sevanspowell Jun 24, 2021
ebd57d3
requestedAssetOutputs -> requestedOutputAssets
sevanspowell Jun 24, 2021
810ee61
Make implementation of addMintValueToChangeMaps clearer
sevanspowell Jun 24, 2021
1f9a363
Use scanl and treat generated qtys as diffs to get asc partial order
sevanspowell Jun 25, 2021
7890bd7
Use Monoidal properties of TokenBundle/Map where it makes sense to
sevanspowell Jun 25, 2021
93109fd
Use Monoidal properties of TokenQuantity
sevanspowell Jun 25, 2021
0ef7c04
Fix minor formatting issues.
jonathanknowles Jun 29, 2021
44a6a89
Minimize the responsibility of `makeChangeForNonUserSpecifiedOutputs`.
jonathanknowles Jun 25, 2021
16ad726
Improve documentation for minting and burning.
jonathanknowles Jun 29, 2021
c1f46e6
Make `missingOutputAssets` resilient to changes in `OutputsInsufficie…
jonathanknowles Jun 29, 2021
47ad1e2
Make pre-condition check for `performSelection` more concise.
jonathanknowles Jun 29, 2021
a941675
Fix comment for minimum ada quantity pre-condition of `performSelecti…
jonathanknowles Jun 29, 2021
4657ea6
Simplify implementation of `changeForNonUserSpecifiedAssets`.
jonathanknowles Jun 29, 2021
35ec8b9
Make definition of `totalOutputValue` consistent with `totalInputValue`.
jonathanknowles Jun 29, 2021
a44880e
Simplify folds in `{addMint,removeBurn}values{To,From}ChangeMaps`.
jonathanknowles Jun 29, 2021
36e4cce
Simplify definition of function `fullBalance`.
jonathanknowles Jun 29, 2021
902b75c
Fix typo in documentation for `TokenQuantity.difference`.
jonathanknowles Jun 29, 2021
93c8948
Add property `TokenQuantitySpec.prop_add_difference`.
jonathanknowles Jun 29, 2021
28ba0a7
Clarify auxilliary function definitions in `RoundRobinSpec`.
jonathanknowles Jun 29, 2021
5a10b15
Introduce minimal API change to support minting and burning error.
jonathanknowles Jul 6, 2021
18be06b
Use consistent terminology for minted and burned tokens.
jonathanknowles Jul 7, 2021
4b38d41
Add the `TokenMap.intersection` function.
jonathanknowles Jul 7, 2021
b02cb1a
Add coverage checks for minted and burned assets in `prop_performSele…
jonathanknowles Jul 7, 2021
5b58f1b
Enhance the generators for minted and burned assets in `genSelectionC…
jonathanknowles Jul 8, 2021
4d22d58
Fix erroneous assertion in `onOutputsInsufficient`.
jonathanknowles Jul 8, 2021
8eb87a8
Extract out function `genAssetsToMintAndBurn` within `genMakeChangeDa…
jonathanknowles Jul 8, 2021
96b6a75
Add coverage checks for minting and burning to `prop_makeChange`.
jonathanknowles Jul 8, 2021
378d35f
Add missing coverage for `prop_makeChange`.
jonathanknowles Jul 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/core/src/Cardano/Wallet/Api/Server.hs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ import Cardano.Wallet.Primitive.CoinSelection.MA.RoundRobin
, SelectionResult (..)
, UnableToConstructChangeError (..)
, balanceMissing
, missingOutputAssets
, selectionDelta
)
import Cardano.Wallet.Primitive.Delegation.UTxO
Expand Down Expand Up @@ -3690,6 +3691,13 @@ instance IsServerError ErrSelectAssets where
, "must specify enough ada. Here are the problematic "
, "outputs:\n" <> pretty (indentF 2 $ blockListF xs)
]
OutputsInsufficient e ->
apiError err403 TokensMintedButNotSpentOrBurned $ mconcat
[ "I can't process this transaction because some "
, "minted values were not spent or burned. These "
, "are the values that should be spent or burned: "
, pretty . Flat $ missingOutputAssets e
]
jonathanknowles marked this conversation as resolved.
Show resolved Hide resolved
UnableToConstructChange e ->
apiError err403 CannotCoverFee $ mconcat
[ "I am unable to finalize the transaction, as there is "
Expand Down
1 change: 1 addition & 0 deletions lib/core/src/Cardano/Wallet/Api/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,7 @@ data ApiErrorCode
| SharedWalletNoSuchCosigner
| SharedWalletCannotUpdateKey
| SharedWalletScriptTemplateInvalid
| TokensMintedButNotSpentOrBurned
deriving (Eq, Generic, Show, Data, Typeable)
deriving anyclass NFData

Expand Down
Loading