XRPL-Labs/Xaman-Issue-Tracker

[Improvement] Refactor balance parsing

Opened this issue · 5 comments

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

  • "Return payment" (prefilled amount)
  • ...

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

  • In the transaction list, if Me is not in the Balance Changes, don't show an amount
  • If my account matches either (only one of) the Account or Destination fields, show the other one (Destination or Account) as source or destination, above, or under my balance change at the TX details page with a usual arrow icon.
    • If the <significant currency> in the balance changes between the Account and Destination account differ, then show an exchange icon instead of usual arrow.
  • If my (self) balance changed, but my account is not the Account nor the Destination, then show Account as origin counterparty in the Event details. If my (self), show the Account above me with an arrow to me, and Destination under me, with an arrow from me to Destination.
    • Use a regular arrow, only if the TransactionType.toLowerCase() contains offer or it is a Payment to self it is a trade (exchange) icon (the double arrow icon).

Test transactions / accounts:

  • #322
  • Partial payment by rQHYSEyxX3GKK3F6sXRvdd2NHhUqaxtC6F to rPdvC6ccq8hCdPKSPJkPmyZ4Mi1oG2FFkT: https://bithomp.com/explorer/E788964F86299E0D5CF9ACD30D0E1DC120BBECA1AC0E10C52FED8EE8368BC9EE
  • Passive offer, that was matched async by someone else's transaction, it affected my balance but I didn't initiate it, and I wasn't the beneficiary. It just consumed some of my (rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ) offer: #260
  • 14F19D5265191FC16260168F08C53D0B77EE54B6CF65BED5F9D15E9A6BB1E485, showed XRP<>DKS, while it was DKS/MGT

--

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])

Nice ones to test

Another one to test:

  • For rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ on May 13th, two changes were proposed in #336

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