XRPL-Labs / Xaman-Issue-Tracker

Bugs, improvements, suggestions & release progress (Project boards)
https://xumm.app
14 stars 9 forks source link

[Improvement] Refactor balance parsing #341

Open WietseWind opened 3 years ago

WietseWind commented 3 years ago

Note for refactoring, extra care (obviously: tx history list + tx detail, but extra tests):

Note: regular key detection from signing public key

  1. Always look for 'self', self is the XUMM home screen selected account
  2. Look for the own account in the balance changes output.
    • If there is a non-XRP record, use that one
    • If there only is an XRP record, use that one
  3. If negative, display as outgoing, if positive: incoming
  4. <SIGNIFICANT CURRENCY>: If showing the XRP value & amount is negative (sent) and the Account of the transaction is self, subtract the Fee
    • Unless if the Fee equals the balance thange, then show the Fee as amount (don't subtract)

Notes

Test transactions / accounts:

--

Outcome

Event list

-------------------------
. SignificantCurrency(BalanceChanges[Me])
---- [ If exchanged ] ---
. If present: NON_SignificantCurrency(BalanceChanges[Me])
-------------------------

Tx Details page

-------------------------
| Transaction `Account`
|
| SignificantCurrency(BalanceChanges[Account])
-------------------------
            ||
            \/
- - - - - - - - - - - - -
. `Me` (only if `Me` isn't already either the `Account` or `Destination`) = me)
.        » 'cross' (affected) or 'regular key' (if signing pubkey 
.  SignificantCurrency(BalanceChanges[Me]) || or (if this block shows and `Me` has no balance changes: I only initiated)
- - - - - - - - - - - - -
            ||
            \/
-------------------------
| Transaction `Destination` (even if `Account` and `Destination` are the same, sending to self (trade) = possible)
|
| SignificantCurrency(BalanceChanges[Destination]) -OR- if `Account` and `Destination` are the same: the other change:
-------------------------                               NON_SignificantCurrency(BalanceChanges[Destination])
WietseWind commented 3 years ago

Lib built: https://github.com/XRPL-Labs/TxMutationParser

@N3TC4T Good luck 💋 😇

WietseWind commented 3 years ago

Nice ones to test

WietseWind commented 3 years ago
WietseWind commented 3 years ago

Another one to test:

The change on the tx details page is perfect :)

The change in the event list seems not to have came through: https://q9ged9o.dlvr.cloud/pasted_1.png

It still shows -2 XRP, while that was the delivered amount (that's right) but actually 110 XTK was sent, so if the sender is watching, it should display what was sent.

If the recipient is watching, it should display what was delivered.

Or: they can see both the same if both info is in there, e.g. like this: https://user-images.githubusercontent.com/4756161/118125830-c8144e00-b3f7-11eb-977a-93da7d3e4045.png

WietseWind commented 3 years ago

Also: https://j99h8zr.dlvr.cloud / https://github.com/XRPL-Labs/XUMM-Issue-Tracker/projects/4#card-66535953 / https://bithomp.com/explorer/8F4ADE2E7C5CDA3417C43D7BD1B697F9097757D6B62917AFA354CD6B8C85DD4D