Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Display CIP8 profile info in Transaction Feed #37

Merged
merged 49 commits into from
May 3, 2021

Conversation

isabellewei
Copy link
Contributor

migrated from celo-org/celo-monorepo#6605

Description

This PR includes a refactor of how we handle recipients. When handling recipient info, the paradigm is to put all information into a Recipient object which is passed between components/functions. This parameter is made mandatory, instead of individually passing address/number/name/thumbnail variables individually.

When a user sends a transaction, it uploads symmetric keys which grants the recipient permission to access their profile information. When the recipient receives the transaction, it downloads and decrypts this profile info, saving it in redux.

Transactions in the feed displays CIP8 profile information if it is available for the recipient. This PR does not handle contact list and send flow UI.

Other/Drive-by Changes

Removed recipients from the persist blacklist, because I want to persist valoraRecipientsCache. Previously the only variable in the recipients reducer was the recipientCache (renamed to phoneRecipientCache ), which I guess was blacklisted because we reconstruct it at the start of each app session. Not sure what the impact of this is

Tested

Sending transactions between Android device and iOS emulator

Related issues

Fixes #18 partially

@isabellewei isabellewei requested a review from gnardini February 20, 2021 01:57
@isabellewei isabellewei force-pushed the isabellewei/CIP8valoraIntegration branch from 7e46eb3 to 9b752fc Compare February 20, 2021 02:17
@isabellewei isabellewei force-pushed the isabellewei/displayTransactionProfiles branch from 64bafd3 to 6ba7a7f Compare February 20, 2021 02:28
Copy link
Contributor

@gnardini gnardini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really excited for this changes to land 🙌

I tried building to see this in action but got some errors:

  • When running yarn build:wallet from the repo root I get a bunch of errors and it gets stuck there.
  • After that, I install the ios pods manually but when I run yarn dev:ios or try to install from XCode I get the following errors:
    • /Users/repoDirectory/wallet/node_modules/react-native-geth/ios/RNGeth.swift:462:39: Value of type 'GethKeyStore' has no member 'computeECDHSharedSecret'
    • /Users/repoDirectory/wallet/node_modules/react-native-geth/ios/RNGeth.swift:486:37: Value of type 'GethKeyStore' has no member 'decrypt'
      Do you know what may be the cause or how to fix it?

Copy link
Member

@jeanregisser jeanregisser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow this is looking great! 👍
Thanks for the big effort on this.
And I'm so glad we are using TypeScript 😄

Comment on lines +483 to 484
// TODO: decide what recipient info to collect, now that RecipientKind doesn't exist
usedSearchBar: boolean
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


export function getE164Number(e164Number?: string, recipient?: Recipient) {
return e164Number || (recipient && recipient.e164PhoneNumber)
export function getE164Number(recipient: Recipient, e164Number?: string) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the outside, the ordering of the parameters seems to indicate the recipient number would be used first.
But the implementation does the opposite.
Can we keep the existing ordering?

Copy link
Contributor Author

@isabellewei isabellewei Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order of the parameters has to be recipient first, because it's a required parameter. I flipped the OR statement instead

@@ -52,9 +38,8 @@ function ContactCircle({ contact, size, thumbnailPath, name, address, style }: P
}

const fontColor = getAddressForegroundColor(address || '0x0')
// Mobile # is what default display name when contact isn't saved
if (displayName && displayName !== 'Mobile #') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this case still handled somewhere else?

Copy link
Contributor Author

@isabellewei isabellewei Apr 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah! This is just checking that we don't have an actual name for the recipient, because the name field used to be mandatory and we would save display info in the name variable. Now we can directly check if the name variable exists or not

Comment on lines 206 to 207
const nameA = a.name!.toUpperCase()
const nameB = b.name!.toUpperCase()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way to avoid the !?

@isabellewei
Copy link
Contributor Author

isabellewei commented Apr 28, 2021

Added the account field to TransferFragment, as the account address of the transaction is needed to fetch CIP8 info. When constructing the StandbyTransaction however, there is currently no way to get the account address of the recipient from their wallet address, so the wallet address is used as a placeholder for the account field. This shouldn't affect the functionality of the standby transaction

@isabellewei
Copy link
Contributor Author

Does this address #36?

No currently you can still only look up the recipient from their address

@isabellewei isabellewei changed the base branch from isabellewei/CIP8valoraIntegration to main April 29, 2021 00:35
@isabellewei isabellewei changed the base branch from main to isabellewei/CIP8valoraIntegration April 29, 2021 00:36
@isabellewei isabellewei changed the base branch from isabellewei/CIP8valoraIntegration to main April 29, 2021 00:36
Copy link
Contributor

@gnardini gnardini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing work on this!

There is one more issue which is that when a user creates an account if they don't verify their phone number they don't have any funds so they can't register their DEK and therefore a user sending them money won't be able to give them access.

There's no perfect way around this I think but I guess it's just something to keep in mind.

@@ -272,7 +272,8 @@ export interface TransferItemFragment {
type: TokenTransactionType
hash: string
timestamp: number
address: string
address: string // wallet address (EOA)
account: string // account address (MTW)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naming from the blockchain-api is really confusing 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha definitely, hopefully these comments help

name?: string
contactId?: string // unique ID given by phone OS
thumbnailPath?: string
displayNumber?: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we also add to the inner recipient

  e164PhoneNumber?: string
  address?: string

It will allow us to query using recipient.address or recipient. e164PhoneNumber and will still require one of address and e164PhoneNumber to be present.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh this is a great solution, thanks!

function* addProfile(transaction: TransferItemFragment) {
const address = transaction.account
const newProfile: AddressToRecipient = {}
if (transaction.type === TokenTransactionType.Received) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have many incoming transactions from the same address we will fetch their profile info many times. Something we could do is to add a timestamp to the recipient with the date that the data was last refreshed and only read again of more than X time has passed (an hour? a day?)

What do you think? Also, do you think it makes sense to do it in this PR or create a new issue for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filed an issue! :) #300

Copy link
Contributor

@gnardini gnardini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing job with this!

@isabellewei isabellewei added the automerge Have PR merge automatically when checks pass label May 3, 2021
@mergify mergify bot merged commit 3aff7b6 into main May 3, 2021
@isabellewei isabellewei deleted the isabellewei/displayTransactionProfiles branch May 3, 2021 21:48
@ValoraQA
Copy link

ValoraQA commented May 11, 2021

Hey @isabellewei I have verified this issue using latest released Android internal build V1.14.0 (1004294350) & Test Flight build V1.14.0(58) & observed following:
Observations:

  • It is observed that, while withdrawing CELO user A(Sender) able to see profile name & profile text as profile picture in Recent Feed when user perform transaction through scanning QR code even user has updated profile particular photo. Where for user B (Receiver) only see random profile picture with phone number. Attachment

  • Also in above scenario it is observed that, either Receiver or Sender profile name displayed in respective device but not able to see for both. Attachment

  • It is observe that, user not able to see profile picture when user withdraw or perform transaction without scanning QR code. Only profile name displayed in Activity feed.

Verified On Devices: iPhone SE (14.2), Redmi Note 8 (9.0)

Can you please take a look & let us know if unchecked points are expected or we need to raise tickets for same ?
Thanks..!!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Profile Photos + Names
4 participants