wallet-stack 1.0.0-alpha.133 → 1.0.0-alpha.135

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +1,17 @@
1
1
  import React, { useState } from 'react'
2
2
  import { useTranslation } from 'react-i18next'
3
3
  import { LayoutAnimation, StyleSheet, Text, View } from 'react-native'
4
+ import { formatShortenedAddress } from 'src/account/utils'
4
5
  import AccountNumber from 'src/components/AccountNumber'
5
6
  import Expandable from 'src/components/Expandable'
6
7
  import Touchable from 'src/components/Touchable'
8
+ import VerifiedBadge from 'src/icons/VerifiedBadge'
7
9
  import { Screens } from 'src/navigator/Screens'
8
10
  import { getDisplayName, Recipient, recipientHasNumber } from 'src/recipients/recipient'
11
+ import { useVerifierName } from 'src/recipients/verifier'
9
12
  import colors from 'src/styles/colors'
10
13
  import { typeScale } from 'src/styles/fonts'
11
- import { getDisplayNumberInternational } from 'src/utils/phoneNumbers'
14
+ import { Spacing } from 'src/styles/styles'
12
15
 
13
16
  interface Props {
14
17
  type: 'sent' | 'received' | 'withdrawn'
@@ -36,11 +39,30 @@ export default function UserSection({
36
39
  }
37
40
 
38
41
  const displayName = getDisplayName(recipient, t)
39
- const displayNumber = recipientHasNumber(recipient)
40
- ? getDisplayNumberInternational(recipient.e164PhoneNumber)
41
- : undefined
42
42
  const address = recipient.address || ''
43
43
 
44
+ const verifierName = useVerifierName(recipient.address)
45
+
46
+ // Show short address in the secondary row when the primary (displayName) isn't already
47
+ // a formatted address — i.e., when the recipient has a name or phone number so the
48
+ // address would add information rather than duplicating the primary.
49
+ const hasIdentity = !!recipient.name || recipientHasNumber(recipient)
50
+ const shortAddress =
51
+ hasIdentity && recipient.address ? formatShortenedAddress(recipient.address) : undefined
52
+
53
+ const secondaryContent = verifierName ? (
54
+ <View style={styles.secondaryContent}>
55
+ {!!shortAddress && <Text style={styles.secondaryText}>{shortAddress}</Text>}
56
+ <VerifiedBadge
57
+ color={colors.contentSecondary}
58
+ testID={testID ? `${testID}/VerifierBadge` : undefined}
59
+ />
60
+ <Text style={styles.secondaryText}>{verifierName}</Text>
61
+ </View>
62
+ ) : shortAddress ? (
63
+ <Text style={styles.secondaryText}>{shortAddress}</Text>
64
+ ) : null
65
+
44
66
  const sectionLabel = {
45
67
  received: t('receivedFrom'),
46
68
  sent: t('sentTo'),
@@ -54,16 +76,14 @@ export default function UserSection({
54
76
  <Text style={styles.sectionLabel}>{sectionLabel}</Text>
55
77
  <Touchable onPress={toggleExpanded} disabled={!expandable}>
56
78
  <>
57
- <Expandable isExpandable={expandable && !displayNumber} isExpanded={expanded}>
79
+ <Expandable isExpandable={expandable && !secondaryContent} isExpanded={expanded}>
58
80
  <Text style={styles.username} testID={`${testID}/name`}>
59
81
  {displayName}
60
82
  </Text>
61
83
  </Expandable>
62
- {!!displayNumber && (
63
- <Expandable isExpandable={expandable && !!displayNumber} isExpanded={expanded}>
64
- <Text style={styles.phoneNumber} testID={`${testID}/number`}>
65
- {displayNumber}
66
- </Text>
84
+ {!!secondaryContent && (
85
+ <Expandable isExpandable={expandable} isExpanded={expanded}>
86
+ <View testID={`${testID}/address`}>{secondaryContent}</View>
67
87
  </Expandable>
68
88
  )}
69
89
  </>
@@ -104,10 +124,16 @@ const styles = StyleSheet.create({
104
124
  username: {
105
125
  ...typeScale.bodyMedium,
106
126
  },
107
- phoneNumber: {
127
+ secondaryText: {
108
128
  ...typeScale.bodySmall,
109
129
  color: colors.contentSecondary,
110
130
  },
131
+ secondaryContent: {
132
+ flexDirection: 'row',
133
+ alignItems: 'center',
134
+ gap: Spacing.Tiny4,
135
+ flexShrink: 1,
136
+ },
111
137
  avatarContainer: {
112
138
  flex: 1,
113
139
  justifyContent: 'center',
@@ -47,7 +47,6 @@ import {
47
47
  mockClaimRewardTransaction,
48
48
  mockCusdAddress,
49
49
  mockCusdTokenId,
50
- mockDisplayNumber2,
51
50
  mockE164Number2,
52
51
  mockEarnClaimRewardTransaction,
53
52
  mockEarnDepositTransaction,
@@ -326,8 +325,8 @@ describe('TransactionDetailsScreen', () => {
326
325
  const nameComponent = getByTestId('TransferSent/name')
327
326
  expect(getElementText(nameComponent)).toEqual(mockName)
328
327
 
329
- const numberComponent = getByTestId('TransferSent/number')
330
- expect(getElementText(numberComponent)).toEqual(mockDisplayNumber2)
328
+ const addressComponent = getByTestId('TransferSent/address')
329
+ expect(getElementText(addressComponent)).toEqual('0x8C3b...ca4E')
331
330
 
332
331
  expect(getByTestId('TransactionDetails/FeeRowItem')).toHaveTextContent('0.01 CELO', {
333
332
  exact: false,
@@ -359,8 +358,8 @@ describe('TransactionDetailsScreen', () => {
359
358
  const nameComponent = getByTestId('TransferReceived/name')
360
359
  expect(getElementText(nameComponent)).toEqual(mockName)
361
360
 
362
- const numberComponent = getByTestId('TransferReceived/number')
363
- expect(getElementText(numberComponent)).toEqual(mockDisplayNumber2)
361
+ const addressComponent = getByTestId('TransferReceived/address')
362
+ expect(getElementText(addressComponent)).toEqual('0x8C3b...ca4E')
364
363
 
365
364
  const totalComponent = getByTestId('TotalLineItem/Total')
366
365
  expect(getElementText(totalComponent)).toEqual('€4.00')
@@ -381,7 +380,8 @@ describe('TransactionDetailsScreen', () => {
381
380
  const nameComponent = getByTestId('RewardReceived/name')
382
381
  expect(getElementText(nameComponent)).toEqual('feedItemRewardReceivedTitle')
383
382
 
384
- expect(queryByTestId('RewardReceived/number')).toBeNull()
383
+ // Rewards senders don't have a known verifier, so the verifier composite isn't shown.
384
+ expect(queryByTestId('RewardReceived/VerifierBadge')).toBeNull()
385
385
 
386
386
  const totalComponent = getByTestId('TotalLineItem/Total')
387
387
  expect(getElementText(totalComponent)).toEqual('€4.00')
@@ -69,17 +69,6 @@ export function getDisplayPhoneNumber(phoneNumber: string, defaultCountryCode: s
69
69
  }
70
70
  }
71
71
 
72
- export function getDisplayNumberInternational(e164PhoneNumber: string) {
73
- const countryCode = getCountryCode(e164PhoneNumber)
74
- const phoneDetails = parsePhoneNumber(e164PhoneNumber, (countryCode || '').toString())
75
- if (phoneDetails) {
76
- return phoneDetails.displayNumberInternational
77
- } else {
78
- // Fallback to input instead of showing nothing for invalid numbers
79
- return e164PhoneNumber
80
- }
81
- }
82
-
83
72
  export function isE164NumberStrict(phoneNumber: string) {
84
73
  try {
85
74
  const parsedPhoneNumber = phoneUtil.parse(phoneNumber)