[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
- Always look for 'self', self is the XUMM home screen selected account
- 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
- If negative, display as outgoing, if positive: incoming
<SIGNIFICANT CURRENCY>
: If showing the XRP value & amount is negative (sent) and theAccount
of the transaction is self, subtract theFee
- 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
orDestination
fields, show the other one (Destination
orAccount
) 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 theAccount
andDestination
account differ, then show an exchange icon instead of usual arrow.
- If the
- If
my
(self) balance changed, but my account is not theAccount
nor theDestination
, then showAccount
as origin counterparty in the Event details. Ifmy
(self), show theAccount
above me with an arrow to me, andDestination
under me, with an arrow fromme
to Destination.- Use a regular arrow, only if the TransactionType.toLowerCase() contains
offer
or it is a Payment toself
it is a trade (exchange) icon (the double arrow icon).
- Use a regular arrow, only if the TransactionType.toLowerCase() contains
Test transactions / accounts:
- #322
- Partial payment by
rQHYSEyxX3GKK3F6sXRvdd2NHhUqaxtC6F
torPdvC6ccq8hCdPKSPJkPmyZ4Mi1oG2FFkT
: 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])
Lib built:
https://github.com/XRPL-Labs/TxMutationParser
@N3TC4T Good luck 💋 😇
Nice ones to test
- Cancel escrow from someone else, own account
rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ
is not an involved party, just signing: https://bithomp.com/explorer/FF1EE042DD3B11AFA3158319D4447101FE69F62465C15A9957BD2EE0FAF35409 - Finish escrow from & to someone else (own account
rwietsevLFg8XSmG3bEZzFein1g8RBqWDZ
is intermediate) https://bithomp.com/explorer/5E62A5FFFFDD29BB58139CC0D57F7CA45559674C417963F6631BC83102377E51
- Account:
rQamE9ddZiRZLKRAAzwGKboQ8rQHgesjEs
, sample tx:F59BBE153A4BBB9A7EFF6BA266A6C1C158828659755116D6A93FF57DA90A8241
- XUMM shows here (2.0.2) that it was an exchange, while it was just the creation of the offer: nothing was filled: https://lurxtau.dlvr.cloud/pasted_2.png - Add support forImmediateOrCancel
andfillOrKill
order balance change display: if nothing was exchanged (didn't end up in the books): don't show the exchange for amount.
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