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

[Improvement] Improve amount (token) handling: small amounts & NFT's #314

Closed
8 tasks done
WietseWind opened this issue Feb 19, 2021 · 1 comment
Closed
8 tasks done
Assignees
Labels
App iOS/Android App

Comments

@WietseWind
Copy link
Member

WietseWind commented Feb 19, 2021

Changes:

Rounding

XUMM currently rounds at 6 decimals. When this amount of decimals is exceeded, XUMM simply shows zero. This issue addresses this: both the rounding should be upgraded (more decimals) and the way we display smaller values (rounded values) should be changed.

  • Change 1. Upgrade the amount of max. decimals in XUMM to 8 (behind the decimal sign), so smallest regular amount: 0.12345678
  • Change 2. In the transaction explanation (Events » TX » All the way down, text view of transaction) we should never round, always show the full raw amount: https://bqtxpnf.dlvr.cloud/pasted_1.png
  • Bug fix: a Sign Request now processes the amount AFTER rounding, so if an amount is really really small, the sign request *not only displays zero (should be fixed, see changes below), but the sign request also rejects signing as it says the amount is zero. It should just go ahead, since in fact it isn't zero: https://mt8h1ah.dlvr.cloud/pasted_2.png » https://mt8h1ah.dlvr.cloud/pasted_1.png

Displaying rounded (non-zero) values with 'horizontal ellipsis' UTF-8 character:

When a value is more than zero (non-zero) but due to rounding/slicing it is as good as zero, we simply show a zero now. We must let the user know that the value is as good as zero, but it is not.

  • Change 3. When a balance / transaction / ... is displayed as zero BUT actually is higher non-zero, just really small, at some places we should show a zero and ellipsis, to indicate that it is zero-something. So previously where we would display: 0, we now display: 0…. Screens to pay extra attention to this: Token balance (home screen), Token details modal (tap Token on home screen), Event list, Event Details page, Sign Request, TX Send confirmation screen.

Allow to show rounded (underlying) amount

At specific places, when (see Change 2) a small non-zero (0…) amount is tapped, we should explain what is happening, and what the actual value is.

  • Change 4: allow tapping amount if small non-zero (0…), and display an alert, title: Really small amount, text: The amount is to small to display:\n{the full, non-truncated/rounded amount}. Button: OK. This should be possible at: Token (home screen) details Modal (balance), Event details Amount (top), Sign Request.

Displaying NFT values

We are going to treat the smallest amounts possible (to issue / transact) on the XPRL as NFT's. They can't be divided, they can only be sent in full numbers, and most likely even only one (smallest amount) will be issued, and so only that one token can be transferred.

Background info

One can issue (and transact) with 80 zeroes behind the decimal sign, and then a 1, which is the smallest amount. The float notation would be:
0.000000000000000000000000000000000000000000000000000000000000000000000000000000001
The scientific notation would be:
1000000000000000e-96

The XRPL accepts both notations when SENDING transactions. When fetching info from the XRPL (eg. account_lines balance, or account_tx delivered amount) the XRPL will always return the scientific notation.

The change

Proposed (sample) code to parse (read / write) NFT values:
https://gist.github.com/WietseWind/5ffbf67cd982a7e9bd8f0ded52e60fe3

Sample code: https://hhq92dz.dlvr.cloud/pasted_1.png
Output: https://hhq92dz.dlvr.cloud/pasted_2.png

So the xrplValueToNft function takes an XRPL amount, and returns false if it's not an NFT. If the amount is super small (> 70 zeroes, then an amount) we consider it an NFT, and treat the balance as such.

  • Change 5: Support displaying XRPL amounts as NFT amounts when displaying: Token balance (home screen), Token detail screen, Token Send flow, Token Send tx confirmation screen, Event list amount, Event details amount (top), Sign Request
  • Change 6: When a Trust Line balance is non-false when passed to xrplValueToNft (so: we consider it an NFT), the send-flow (and sign requests) is (are) only allowed to specify FULL numbers, so no decimals. 1 is allowed, 10 is allowed, 123456 is allowed (all considering the balance through xrplValueToNft is sufficient), but 0.5 is not allowed (decimal).
  • Change 7. When a Trust Line balance is non-false when passed to xrplValueToNft, all amounts entered (see 6) when sending (Send flow, Send flow review: change amount, Sign Request, Sign Request without amount (user enters) the entered amount should be compared to the available balance & must be converted to XRPL notation before signing and sending, using the nftValuetoXrpl method (see sample)
@WietseWind WietseWind added the App iOS/Android App label Feb 19, 2021
@WietseWind
Copy link
Member Author

Standard proposal: XRPLF/XRPL-Standards#30

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App iOS/Android App
Projects
None yet
Development

No branches or pull requests

2 participants