Page MenuHomePhabricator

[Cashtab] Added received from address to txHistory display
ClosedPublic

Authored by kieran709 on May 24 2022, 19:24.

Details

Summary

Related to T2407 & T2413. Received txs now display either the 1) Name if it is present or 2) the first five characters of the sender's address (minus the prefix).

Test Plan

cd web/cashtab && npm start
from the Tx History tab:
observe that all received Txs now show "From: [someone]" inline with the Received h3.
if no current Txs are from contacts, add one of the tx senders to your contacts,
from the Settings tab:
give tx sender's wallet a nickname and navigate back to tx history (may require hard refresh)
observe that the nickname now shows instead of the 5 digits from the replyAddress
from the settings tab:
delete a named contact and navigate back to TxHistory (may require hard refresh)
observe that the removed wallet now shows as the 5 character abbreviation

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

See Home.js

contactList is available directly from wallet context. If it is being used by Tx.js, it should be passed down to that component from this state field. It is not good practice to call it up from local storage in Tx.js ... which would be calling it up for every transaction displayed on the home page.

Best approach is probably to modify TxHistory.js to not flatten contactList and instead pass it directly to Tx.js, where it can be parsed.

This revision now requires changes to proceed.May 25 2022, 19:31

I am thinking I will pass down the contactList, but leave the flattened array as it is easier to check the addressesInContactList array than to iterate through each contact object to access the addresses for some of the conditional formatting. Let me know what you think of this approach, if that isn't a good solution I can try out some other options.

Passed contactList as a prop through TxHistory, removed unnecessary code from Tx.js related to retrieving the contactList.

image.png (364×464 px, 32 KB)

Seeing this, I think it only makes sense to display the info if the tx is from a contact. Otherwise "view on be.cash" is sufficient.

Also, I think just from {contactName} is best. No need for the :

e.g.

image.png (207×465 px, 18 KB)

web/cashtab/src/components/Home/Tx.js
837 ↗(On Diff #33700)

We talked about a task to correct this namer typo elsewhere -- it can just be correct in this diff ;)

responding to review feedback

bytesofman requested changes to this revision.Jun 7 2022, 22:08
  • lowercase "from"
  • only one "from" ... not all of these

image.png (593×469 px, 65 KB)

web/cashtab/src/components/Home/Tx.js
454 ↗(On Diff #33866)

lowercase, i.e. from

This revision now requires changes to proceed.Jun 7 2022, 22:08

Responding to review feedback

bytesofman requested changes to this revision.Jun 8 2022, 16:53
bytesofman added inline comments.
web/cashtab/src/components/Home/Tx.js
446 ↗(On Diff #33891)

What happens if contactAddress !== dataAddress? Maybe we can ignore this case but might as well just set result to an empty string.

452 ↗(On Diff #33891)

This is not a unique key. Try ${txid}${result}

This revision now requires changes to proceed.Jun 8 2022, 16:53

Added logic to handle cases where contactAddress !== dataAddress, and changed the key per review feedback.

bytesofman requested changes to this revision.Jun 8 2022, 18:53
bytesofman added inline comments.
web/cashtab/src/components/Home/Tx.js
449 ↗(On Diff #33902)

Use an else {} block for this

This revision now requires changes to proceed.Jun 8 2022, 18:53

Responding to review feedback

bytesofman requested changes to this revision.Jun 9 2022, 16:19
bytesofman added inline comments.
web/cashtab/src/components/Home/Tx.js
454 ↗(On Diff #33918)

I did suggest the key={${data.txid}${result}} approach, but if you check the dev console you can see it doesn't work:

image.png (658×564 px, 134 KB)

Issue: if "result" is blank, then ${data.txid}${result} will be the same as data.txid

So instead of using result, you will need to map (index, contact), and the key should be ${data.txid}${index}

Check the dev console to make sure you aren't getting these errors.

This revision now requires changes to proceed.Jun 9 2022, 16:19

Responding to review feedback

This revision is now accepted and ready to land.Jun 9 2022, 21:35