wallet-stack 1.0.0-alpha.129 → 1.0.0-alpha.130

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wallet-stack",
3
- "version": "1.0.0-alpha.129",
3
+ "version": "1.0.0-alpha.130",
4
4
  "author": "Valora Inc",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -18,7 +18,7 @@
18
18
  "provenance": true
19
19
  },
20
20
  "engines": {
21
- "node": ">=20"
21
+ "node": ">=20.20.2"
22
22
  },
23
23
  "files": [
24
24
  "tsconfig.json",
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  AddressToDisplayNameType,
3
3
  AddressToE164NumberType,
4
+ AddressToVerifiedByType,
4
5
  AddressValidationType,
5
6
  E164NumberToAddressType,
6
7
  } from 'src/identity/reducer'
@@ -31,6 +32,7 @@ export interface UpdateE164PhoneNumberAddressesAction {
31
32
  type: Actions.UPDATE_E164_PHONE_NUMBER_ADDRESSES
32
33
  e164NumberToAddress: E164NumberToAddressType
33
34
  addressToE164Number: AddressToE164NumberType
35
+ addressToVerifiedBy: AddressToVerifiedByType
34
36
  }
35
37
 
36
38
  export interface UpdateKnownAddressesAction {
@@ -162,11 +164,13 @@ export const endFetchingAddresses = (
162
164
 
163
165
  export const updateE164PhoneNumberAddresses = (
164
166
  e164NumberToAddress: E164NumberToAddressType,
165
- addressToE164Number: AddressToE164NumberType
167
+ addressToE164Number: AddressToE164NumberType,
168
+ addressToVerifiedBy: AddressToVerifiedByType = {}
166
169
  ): UpdateE164PhoneNumberAddressesAction => ({
167
170
  type: Actions.UPDATE_E164_PHONE_NUMBER_ADDRESSES,
168
171
  e164NumberToAddress,
169
172
  addressToE164Number,
173
+ addressToVerifiedBy,
170
174
  })
171
175
 
172
176
  export const updateKnownAddresses = (
@@ -115,7 +115,8 @@ describe('Fetch Addresses Saga', () => {
115
115
  .put(
116
116
  updateE164PhoneNumberAddresses(
117
117
  { [mockE164Number]: ['0xabc'] },
118
- { '0xabc': mockE164Number }
118
+ { '0xabc': mockE164Number },
119
+ {}
119
120
  )
120
121
  )
121
122
  .run()
@@ -151,7 +152,45 @@ describe('Fetch Addresses Saga', () => {
151
152
  .put(
152
153
  updateE164PhoneNumberAddresses(
153
154
  { [mockE164Number]: ['0xabc', '0xdef'] },
154
- { '0xabc': mockE164Number, '0xdef': mockE164Number }
155
+ { '0xabc': mockE164Number, '0xdef': mockE164Number },
156
+ {}
157
+ )
158
+ )
159
+ .put(requireSecureSend(mockE164Number, AddressValidationType.PARTIAL))
160
+ .run()
161
+ })
162
+
163
+ it('uses verifiedAddresses as source of truth when present', async () => {
164
+ const mockE164NumberToAddress = {
165
+ [mockE164Number]: [mockAccount.toLowerCase()],
166
+ }
167
+ // addresses only contains DB-verified addresses (backward compat),
168
+ // verifiedAddresses contains all (DB + SC) and is the source of truth
169
+ mockFetch.mockResponseOnce(
170
+ JSON.stringify({
171
+ data: {
172
+ addresses: ['0xAbC'],
173
+ verifiedAddresses: [
174
+ { address: '0xAbC', verifiedBy: 'valora' },
175
+ { address: '0xDef', verifiedBy: 'minipay' },
176
+ ],
177
+ },
178
+ })
179
+ )
180
+
181
+ await expectSaga(fetchAddressesAndValidateSaga, fetchAddressesAndValidate(mockE164Number))
182
+ .provide([
183
+ [select(e164NumberToAddressSelector), mockE164NumberToAddress],
184
+ [select(walletAddressSelector), mockAccount],
185
+ [call(retrieveSignedMessage), 'some signed message'],
186
+ [select(secureSendPhoneNumberMappingSelector), {}],
187
+ ])
188
+ .put(updateE164PhoneNumberAddresses({ [mockE164Number]: undefined }, {}))
189
+ .put(
190
+ updateE164PhoneNumberAddresses(
191
+ { [mockE164Number]: ['0xabc', '0xdef'] },
192
+ { '0xabc': mockE164Number, '0xdef': mockE164Number },
193
+ { '0xabc': 'valora', '0xdef': 'minipay' }
155
194
  )
156
195
  )
157
196
  .put(requireSecureSend(mockE164Number, AddressValidationType.PARTIAL))
@@ -159,10 +159,22 @@ export function* fetchAddressesAndValidateSaga({
159
159
  // Clear existing entries for those numbers so our mapping consumers know new status is pending.
160
160
  yield* put(updateE164PhoneNumberAddresses({ [e164Number]: undefined }, {}))
161
161
 
162
- const walletAddresses: string[] = yield* call(fetchWalletAddresses, e164Number)
162
+ const { addresses, verifiedAddresses } = yield* call(fetchWalletAddresses, e164Number)
163
+
164
+ // When `verifiedAddresses` is present, use it as source of truth:
165
+ // it includes addresses verified by both CPV and SocialConnect.
166
+ // The `addresses` field is used for backward compatibility.
167
+ const walletAddresses = verifiedAddresses ? verifiedAddresses.map((v) => v.address) : addresses
163
168
 
164
169
  const e164NumberToAddressUpdates: E164NumberToAddressType = {}
165
170
  const addressToE164NumberUpdates: AddressToE164NumberType = {}
171
+ const addressToVerifiedByUpdates: Record<string, string> = {}
172
+
173
+ if (verifiedAddresses) {
174
+ for (const { address, verifiedBy } of verifiedAddresses) {
175
+ addressToVerifiedByUpdates[address] = verifiedBy
176
+ }
177
+ }
166
178
 
167
179
  if (!walletAddresses.length) {
168
180
  Logger.debug(TAG + '@fetchAddressesAndValidate', `No addresses for number`)
@@ -197,7 +209,11 @@ export function* fetchAddressesAndValidateSaga({
197
209
  yield* put(requireSecureSend(e164Number, addressValidationType))
198
210
  }
199
211
  yield* put(
200
- updateE164PhoneNumberAddresses(e164NumberToAddressUpdates, addressToE164NumberUpdates)
212
+ updateE164PhoneNumberAddresses(
213
+ e164NumberToAddressUpdates,
214
+ addressToE164NumberUpdates,
215
+ addressToVerifiedByUpdates
216
+ )
201
217
  )
202
218
  yield* put(endFetchingAddresses(e164Number, true))
203
219
  AppAnalytics.track(IdentityEvents.phone_number_lookup_complete)
@@ -265,9 +281,22 @@ function* fetchWalletAddresses(e164Number: string) {
265
281
  throw new Error(`Failed to look up phone number: ${response.status} ${response.statusText}`)
266
282
  }
267
283
 
268
- const { data }: { data: { addresses: string[] } } = yield* call([response, 'json'])
269
-
270
- return data.addresses.map((address) => address.toLowerCase())
284
+ const {
285
+ data,
286
+ }: {
287
+ data: {
288
+ addresses: string[]
289
+ verifiedAddresses?: Array<{ address: string; verifiedBy: string }>
290
+ }
291
+ } = yield* call([response, 'json'])
292
+
293
+ return {
294
+ addresses: data.addresses.map((address) => address.toLowerCase()),
295
+ verifiedAddresses: data.verifiedAddresses?.map((v) => ({
296
+ ...v,
297
+ address: v.address.toLowerCase(),
298
+ })),
299
+ }
271
300
  } catch (error) {
272
301
  Logger.debug(`${TAG}/fetchWalletAddresses`, 'Unable to look up phone number', error)
273
302
  throw new Error('Unable to fetch wallet address for this phone number')
@@ -54,6 +54,10 @@ export interface AddressToVerificationStatus {
54
54
  [address: string]: boolean | undefined
55
55
  }
56
56
 
57
+ export interface AddressToVerifiedByType {
58
+ [address: string]: string | undefined
59
+ }
60
+
57
61
  interface State {
58
62
  addressToE164Number: AddressToE164NumberType
59
63
  // Note: Do not access values in this directly, use the `getAddressFromPhoneNumber` helper in contactMapping
@@ -67,6 +71,8 @@ interface State {
67
71
  secureSendPhoneNumberMapping: SecureSendPhoneNumberMapping
68
72
  // Mapping of address to verification status; undefined entries represent a loading state
69
73
  addressToVerificationStatus: AddressToVerificationStatus
74
+ // Mapping of address to the entity that verified it (e.g. "valora", "minipay")
75
+ addressToVerifiedBy: AddressToVerifiedByType
70
76
  lastSavedContactsHash: string | null
71
77
  shouldRefreshStoredPasswordHash: boolean
72
78
  }
@@ -83,6 +89,7 @@ const initialState: State = {
83
89
  },
84
90
  secureSendPhoneNumberMapping: {},
85
91
  addressToVerificationStatus: {},
92
+ addressToVerifiedBy: {},
86
93
  lastSavedContactsHash: null,
87
94
  shouldRefreshStoredPasswordHash: false,
88
95
  }
@@ -114,6 +121,10 @@ export const reducer = (
114
121
  ...state.e164NumberToAddress,
115
122
  ...action.e164NumberToAddress,
116
123
  },
124
+ addressToVerifiedBy: {
125
+ ...state.addressToVerifiedBy,
126
+ ...action.addressToVerifiedBy,
127
+ },
117
128
  }
118
129
  case Actions.UPDATE_KNOWN_ADDRESSES:
119
130
  return {
@@ -4,6 +4,7 @@ export const e164NumberToAddressSelector = (state: RootState) => state.identity.
4
4
  export const addressToVerificationStatusSelector = (state: RootState) =>
5
5
  state.identity.addressToVerificationStatus
6
6
  export const addressToE164NumberSelector = (state: RootState) => state.identity.addressToE164Number
7
+ export const addressToVerifiedBySelector = (state: RootState) => state.identity.addressToVerifiedBy
7
8
  export const secureSendPhoneNumberMappingSelector = (state: RootState) =>
8
9
  state.identity.secureSendPhoneNumberMapping
9
10
  export const importContactsProgressSelector = (state: RootState) =>
@@ -9,7 +9,7 @@ import {
9
9
  addressToVerificationStatusSelector,
10
10
  e164NumberToAddressSelector,
11
11
  } from 'src/identity/selectors'
12
- import Logo from 'src/images/Logo'
12
+ import Checkmark from 'src/icons/Checkmark'
13
13
  import {
14
14
  Recipient,
15
15
  RecipientType,
@@ -63,12 +63,9 @@ function RecipientItem({ recipient, onSelectRecipient, loading, selected }: Prop
63
63
  DefaultIcon={() => renderDefaultIcon(recipient)} // no need to honor color props here since the color we need match the defaults
64
64
  />
65
65
  {!!showAppIcon && (
66
- <Logo
67
- color={Colors.contentSecondary}
68
- style={styles.appIcon}
69
- size={ICON_SIZE}
70
- testID="RecipientItem/AppIcon"
71
- />
66
+ <View style={styles.appIcon} testID="RecipientItem/AppIcon">
67
+ <Checkmark color={Colors.contentTertiary} height={ICON_SIZE} width={ICON_SIZE} />
68
+ </View>
72
69
  )}
73
70
  </View>
74
71
  <View style={styles.contentContainer}>
@@ -129,13 +126,8 @@ const styles = StyleSheet.create({
129
126
  top: 22,
130
127
  left: 22,
131
128
  backgroundColor: Colors.accent,
132
- padding: 4,
133
129
  borderRadius: 100,
134
- // To override the default shadow props on the logo
135
- shadowColor: undefined,
136
- shadowOpacity: undefined,
137
- shadowRadius: undefined,
138
- shadowOffset: undefined,
130
+ padding: 2,
139
131
  },
140
132
  })
141
133
 
@@ -67,6 +67,7 @@ import {
67
67
  v235Schema,
68
68
  v251Schema,
69
69
  v253Schema,
70
+ v254Schema,
70
71
  v28Schema,
71
72
  v2Schema,
72
73
  v35Schema,
@@ -1937,4 +1938,12 @@ describe('Redux persist migrations', () => {
1937
1938
  expectedSchema.home = _.omit(oldSchema.home, 'hasSeenDivviBottomSheet')
1938
1939
  expect(migratedSchema).toStrictEqual(expectedSchema)
1939
1940
  })
1941
+
1942
+ it('works from 254 to 255', () => {
1943
+ const oldSchema = {
1944
+ ...v254Schema,
1945
+ }
1946
+ const migratedSchema = migrations[255](oldSchema)
1947
+ expect(migratedSchema.identity.addressToVerifiedBy).toStrictEqual({})
1948
+ })
1940
1949
  })
@@ -2070,4 +2070,11 @@ export const migrations = {
2070
2070
  ...state,
2071
2071
  home: _.omit(state.home, 'hasSeenDivviBottomSheet'),
2072
2072
  }),
2073
+ 255: (state: any) => ({
2074
+ ...state,
2075
+ identity: {
2076
+ ...state.identity,
2077
+ addressToVerifiedBy: {},
2078
+ },
2079
+ }),
2073
2080
  }
@@ -143,7 +143,7 @@ describe('store state', () => {
143
143
  {
144
144
  "_persist": {
145
145
  "rehydrated": true,
146
- "version": 254,
146
+ "version": 255,
147
147
  },
148
148
  "account": {
149
149
  "acceptedTerms": false,
@@ -245,6 +245,7 @@ describe('store state', () => {
245
245
  "addressToDisplayName": {},
246
246
  "addressToE164Number": {},
247
247
  "addressToVerificationStatus": {},
248
+ "addressToVerifiedBy": {},
248
249
  "askedContactsPermission": false,
249
250
  "e164NumberToAddress": {},
250
251
  "importContactsProgress": {
@@ -30,7 +30,7 @@ const persistConfig: PersistConfig<ReducersRootState> = {
30
30
  key: 'root',
31
31
  // default is -1, increment as we make migrations
32
32
  // See https://github.com/valora-xyz/wallet/tree/main/WALLET.md#redux-state-migration
33
- version: 254,
33
+ version: 255,
34
34
  keyPrefix: `reduxStore-`, // the redux-persist default is `persist:` which doesn't work with some file systems.
35
35
  storage: FSStorage(),
36
36
  blacklist: ['networkInfo', 'alert', 'imports', 'keylessBackup', transactionFeedV2Api.reducerPath],
@@ -243,6 +243,7 @@ describe('SendSelectRecipient', () => {
243
243
  forceTokenId: undefined,
244
244
  recipient: expect.any(Object),
245
245
  origin: SendOrigin.AppSendFlow,
246
+ isMiniPayRecipient: false,
246
247
  })
247
248
  })
248
249
  it('navigates to send amount when address recipient is pressed', async () => {
@@ -280,6 +281,7 @@ describe('SendSelectRecipient', () => {
280
281
  forceTokenId: undefined,
281
282
  recipient: expect.any(Object),
282
283
  origin: SendOrigin.AppSendFlow,
284
+ isMiniPayRecipient: false,
283
285
  })
284
286
  })
285
287
 
@@ -522,6 +524,54 @@ describe('SendSelectRecipient', () => {
522
524
  recipientType: 'PhoneNumber',
523
525
  },
524
526
  origin: SendOrigin.AppSendFlow,
527
+ isMiniPayRecipient: false,
528
+ })
529
+ })
530
+ it('navigates to send amount with isMiniPayRecipient when address is verified by minipay', async () => {
531
+ jest
532
+ .mocked(getRecipientVerificationStatus)
533
+ .mockReturnValue(RecipientVerificationStatus.VERIFIED)
534
+
535
+ const store = createMockStore({
536
+ ...storeWithPhoneVerified,
537
+ identity: {
538
+ secureSendPhoneNumberMapping: {
539
+ [mockE164Number3]: { addressValidationType: AddressValidationType.NONE },
540
+ },
541
+ e164NumberToAddress: { [mockE164Number3]: [mockAccount3] },
542
+ addressToVerifiedBy: { [mockAccount3]: 'minipay' },
543
+ },
544
+ })
545
+
546
+ const { getByTestId } = render(
547
+ <Provider store={store}>
548
+ <SendSelectRecipient {...mockScreenProps({})} />
549
+ </Provider>
550
+ )
551
+ const searchInput = getByTestId('SendSelectRecipientSearchInput')
552
+
553
+ await act(() => {
554
+ fireEvent.changeText(searchInput, mockE164Number3)
555
+ })
556
+ await act(() => {
557
+ fireEvent.press(getByTestId('RecipientItem'))
558
+ })
559
+ await act(() => {
560
+ fireEvent.press(getByTestId('SendOrInviteButton'))
561
+ })
562
+
563
+ expect(navigate).toHaveBeenCalledWith(Screens.SendEnterAmount, {
564
+ isFromScan: false,
565
+ defaultTokenIdOverride: undefined,
566
+ forceTokenId: undefined,
567
+ recipient: {
568
+ address: mockAccount3,
569
+ displayNumber: '(415) 555-0123',
570
+ e164PhoneNumber: mockE164Number3,
571
+ recipientType: 'PhoneNumber',
572
+ },
573
+ origin: SendOrigin.AppSendFlow,
574
+ isMiniPayRecipient: true,
525
575
  })
526
576
  })
527
577
  it('navigates to secure send flow when phone number recipient with multiple addresses, first time seeing it', async () => {
@@ -631,6 +681,7 @@ describe('SendSelectRecipient', () => {
631
681
  recipientType: 'PhoneNumber',
632
682
  },
633
683
  origin: SendOrigin.AppSendFlow,
684
+ isMiniPayRecipient: false,
634
685
  })
635
686
  })
636
687
  it.each([{ searchAddress: mockAccount2 }, { searchAddress: mockAccount3 }])(
@@ -694,6 +745,7 @@ describe('SendSelectRecipient', () => {
694
745
  thumbnailPath: undefined,
695
746
  },
696
747
  origin: SendOrigin.AppSendFlow,
748
+ isMiniPayRecipient: false,
697
749
  })
698
750
  }
699
751
  )
@@ -759,6 +811,7 @@ describe('SendSelectRecipient', () => {
759
811
  thumbnailPath: undefined,
760
812
  },
761
813
  origin: SendOrigin.AppSendFlow,
814
+ isMiniPayRecipient: false,
762
815
  })
763
816
  }
764
817
  )
@@ -21,6 +21,7 @@ import { getAddressFromPhoneNumber } from 'src/identity/contactMapping'
21
21
  import { AddressValidationType } from 'src/identity/reducer'
22
22
  import { getAddressValidationType } from 'src/identity/secureSend'
23
23
  import {
24
+ addressToVerifiedBySelector,
24
25
  e164NumberToAddressSelector,
25
26
  secureSendPhoneNumberMappingSelector,
26
27
  } from 'src/identity/selectors'
@@ -215,6 +216,7 @@ function SendSelectRecipient({ route }: Props) {
215
216
  const dispatch = useDispatch()
216
217
  const secureSendPhoneNumberMapping = useSelector(secureSendPhoneNumberMappingSelector)
217
218
  const e164NumberToAddress = useSelector(e164NumberToAddressSelector)
219
+ const addressToVerifiedBy = useSelector(addressToVerifiedBySelector)
218
220
  const shareUrl = getAppConfig().experimental?.inviteFriends?.shareUrl ?? null
219
221
 
220
222
  const forceTokenId = route.params?.forceTokenId
@@ -314,6 +316,7 @@ function SendSelectRecipient({ route }: Props) {
314
316
  address,
315
317
  },
316
318
  origin: SendOrigin.AppSendFlow,
319
+ isMiniPayRecipient: addressToVerifiedBy?.[address] === 'minipay',
317
320
  })
318
321
  }
319
322
 
@@ -176,6 +176,7 @@ describe('ValidateRecipientAccount', () => {
176
176
  ...mockInvitableRecipient2,
177
177
  address: mockAccountInvite,
178
178
  },
179
+ isMiniPayRecipient: false,
179
180
  })
180
181
  })
181
182
  })
@@ -42,6 +42,7 @@ interface StateProps {
42
42
  validationSuccessful: boolean
43
43
  error?: ErrorMessages | null
44
44
  validatedAddress?: string
45
+ isMiniPayRecipient: boolean
45
46
  }
46
47
 
47
48
  interface State {
@@ -77,6 +78,8 @@ const mapStateToProps = (state: RootState, ownProps: OwnProps): StateProps => {
77
78
  secureSendPhoneNumberMapping
78
79
  )
79
80
  const validatedAddress = getSecureSendAddress(recipient, secureSendPhoneNumberMapping)
81
+ const isMiniPayRecipient =
82
+ !!validatedAddress && state.identity.addressToVerifiedBy?.[validatedAddress] === 'minipay'
80
83
 
81
84
  return {
82
85
  recipient,
@@ -84,6 +87,7 @@ const mapStateToProps = (state: RootState, ownProps: OwnProps): StateProps => {
84
87
  addressValidationType,
85
88
  error,
86
89
  validatedAddress,
90
+ isMiniPayRecipient,
87
91
  }
88
92
  }
89
93
 
@@ -121,6 +125,7 @@ export class ValidateRecipientAccount extends React.Component<Props, State> {
121
125
  isFromScan: false,
122
126
  forceTokenId: route.params.forceTokenId,
123
127
  defaultTokenIdOverride: route.params.defaultTokenIdOverride,
128
+ isMiniPayRecipient: this.props.isMiniPayRecipient,
124
129
  })
125
130
  }
126
131