-
Notifications
You must be signed in to change notification settings - Fork 214
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
Fork the not_enough_money
HTTP API error.
#4366
Merged
Merged
Conversation
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
We can verify that `NoUtxosAvailable` correctly serialises as `no_utxos_available`.
jonathanknowles
force-pushed
the
jonathanknowles/no-utxos-available
branch
from
December 20, 2023 05:09
b5840fe
to
67b635e
Compare
jonathanknowles
changed the base branch from
master
to
jonathanknowles/api-amount
December 20, 2023 05:10
jonathanknowles
changed the title
Add
Fork the Dec 20, 2023
no_utxos_available
error to HTTP API.not_enough_money
HTTP API error.
paweljakubas
approved these changes
Dec 20, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very fond of using decodeErrorInfo
and your reformulation of the error 👍
WilliamKingNoel-Bot
pushed a commit
that referenced
this pull request
Dec 20, 2023
…This PR forks the HTTP API error `not_enough_money` into two separate errors: - `not_enough_money` for when there **_really_** isn't enough money - `no_utxos_available` for when there **_might_** be enough money, but there are no UTxOs available These two cases can require subtly different workarounds from the user. ## Details This PR solves two problems. ### Problem 1 The `not_enough_money` error is **_inappropriate_** in the case where the reward balance alone would be sufficient to cover the amount required. For example, suppose a user has a wallet with: - no UTxOs; - an unspent reward balance of `1,000,000,000` ada. Suppose that the user attempts to make a payment transaction of `10` ada. In this case, the attempt will fail because: - every transaction is required to spend at least one UTxO; but - the wallet has no UTxOs available. But the user will receive a misleading `not_enough_money` error, even though they have more than enough money. This PR solves this problem by always using `no_utxos_available` when there are no UTxOs. ### Problem 2 In the case where UTxOs **_are_** available, but their value is insufficient, we currently attempt to embed information about the shortfall within the error message string: > ``` > I can't process this payment as there are not enough funds in the wallet. I am missing: > - lovelace: 123,456 lovelace > - assets: ... <information embedded within string> > ``` This information is valuable for UI clients that wish to inform users how much extra value they would need, but the information is tricky for UI clients to parse, as it's embedded within a **_string_**. We wish to turn the shortfall case into a **_machine-readable_** error with a specified JSON encoding (see #4348). However, this error would not be appropriate for the case where there are no UTxOs available at all, as there would not necessarily even be a "shortfall". This PR avoids this problem by giving the former case (no UTxOs available) its own dedicated error that will not be affected by #4348. Source commit: 15f75af
github-merge-queue bot
pushed a commit
that referenced
this pull request
Dec 22, 2023
## Summary This PR attempts to fix the end-to-end tests. ## Details If the wallet is asked to create a transaction in a situation where there are no UTxOs available, then the wallet will return a `no_utxos_available` error instead of a `not_enough_money` error. See: - #4366 - https://github.com/cardano-foundation/cardano-wallet/actions/runs/7294574003/job/19879662240#step:12:906 ## Issue ADP-3248
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
ADP-3248
Summary of user-facing change
If the wallet is asked to create a transaction in a situation where there are no UTxOs available, then the wallet will return a
no_utxos_available
error instead of anot_enough_money
error.Details
This PR forks the HTTP API error
not_enough_money
into two separate errors:not_enough_money
for when there really isn't enough money
no_utxos_available
for when there might be enough money, but there are definitely no UTxOs available
These two cases can require subtly different workarounds from the user.
Details
This PR solves two problems.
Problem 1
The
not_enough_money
error is inappropriate in the case where the reward balance alone would be sufficient to cover the amount required.For example, suppose a user has a wallet with:
1,000,000,000
ada.Suppose that the user attempts to make a payment transaction of
10
ada. In this case, the attempt will fail because:But the user will receive a misleading
not_enough_money
error, even though they have more than enough money.This PR solves this problem by always using
no_utxos_available
when there are no UTxOs.Problem 2
In the case where UTxOs are available, but their value is insufficient, we currently attempt to embed information about the shortfall within the error message string:
This information is valuable for UI clients that wish to inform users how much extra value they would need, but the information is tricky for UI clients to parse, as it's embedded within a string.
We wish to turn the shortfall case into a machine-readable error with a specified JSON encoding (see #4348). However, this error would not be appropriate for the case where there are no UTxOs available at all, as there would not necessarily even be a "shortfall".
This PR avoids this problem by giving the former case (no UTxOs available) its own dedicated error that will not be affected by #4348.