wallet-stack 1.0.0-alpha.129 → 1.0.0-alpha.131
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/locales/base/translation.json +2 -1
- package/package.json +2 -2
- package/src/identity/actions.ts +5 -1
- package/src/identity/contactMapping.test.ts +41 -2
- package/src/identity/contactMapping.ts +34 -5
- package/src/identity/reducer.ts +11 -0
- package/src/identity/selectors.ts +1 -0
- package/src/recipients/RecipientItemV2.tsx +5 -13
- package/src/redux/migrations.test.ts +9 -0
- package/src/redux/migrations.ts +7 -0
- package/src/redux/store.test.ts +2 -1
- package/src/redux/store.ts +1 -1
- package/src/send/SendEnterAmount.test.tsx +3 -3
- package/src/send/SendSelectRecipient.test.tsx +125 -0
- package/src/send/SendSelectRecipient.tsx +15 -10
- package/src/send/ValidateRecipientAccount.test.tsx +1 -0
- package/src/send/ValidateRecipientAccount.tsx +5 -0
- package/src/send/useSendFilterChips.ts +4 -1
|
@@ -2269,7 +2269,8 @@
|
|
|
2269
2269
|
"insufficientBalanceWarning": {
|
|
2270
2270
|
"title": "You need more {{tokenSymbol}}",
|
|
2271
2271
|
"description": "Insufficient {{tokenSymbol}} balance. Try a smaller amount or choose a different asset."
|
|
2272
|
-
}
|
|
2272
|
+
},
|
|
2273
|
+
"miniPayFilterChip": "MiniPay supported"
|
|
2273
2274
|
},
|
|
2274
2275
|
"jumpstartIntro": {
|
|
2275
2276
|
"title": "Share crypto like a text",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wallet-stack",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.131",
|
|
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",
|
package/src/identity/actions.ts
CHANGED
|
@@ -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
|
|
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(
|
|
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 {
|
|
269
|
-
|
|
270
|
-
|
|
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')
|
package/src/identity/reducer.ts
CHANGED
|
@@ -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
|
|
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
|
-
<
|
|
67
|
-
color={Colors.
|
|
68
|
-
|
|
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
|
-
|
|
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
|
})
|
package/src/redux/migrations.ts
CHANGED
|
@@ -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
|
}
|
package/src/redux/store.test.ts
CHANGED
|
@@ -143,7 +143,7 @@ describe('store state', () => {
|
|
|
143
143
|
{
|
|
144
144
|
"_persist": {
|
|
145
145
|
"rehydrated": true,
|
|
146
|
-
"version":
|
|
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": {
|
package/src/redux/store.ts
CHANGED
|
@@ -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:
|
|
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],
|
|
@@ -258,7 +258,7 @@ describe('SendEnterAmount', () => {
|
|
|
258
258
|
</Provider>
|
|
259
259
|
)
|
|
260
260
|
|
|
261
|
-
expect(getByText('
|
|
261
|
+
expect(getByText('sendEnterAmountScreen.miniPayFilterChip')).toBeTruthy()
|
|
262
262
|
|
|
263
263
|
const tokenBottomSheet = getAllByTestId('TokenBottomSheet')[0]
|
|
264
264
|
const tokens = within(tokenBottomSheet).getAllByTestId('TokenBalanceItem')
|
|
@@ -291,7 +291,7 @@ describe('SendEnterAmount', () => {
|
|
|
291
291
|
</Provider>
|
|
292
292
|
)
|
|
293
293
|
|
|
294
|
-
fireEvent.press(getByText('
|
|
294
|
+
fireEvent.press(getByText('sendEnterAmountScreen.miniPayFilterChip'))
|
|
295
295
|
|
|
296
296
|
const tokenBottomSheet = getAllByTestId('TokenBottomSheet')[0]
|
|
297
297
|
const tokens = within(tokenBottomSheet).getAllByTestId('TokenBalanceItem')
|
|
@@ -305,7 +305,7 @@ describe('SendEnterAmount', () => {
|
|
|
305
305
|
</Provider>
|
|
306
306
|
)
|
|
307
307
|
|
|
308
|
-
expect(queryByText('
|
|
308
|
+
expect(queryByText('sendEnterAmountScreen.miniPayFilterChip')).toBeFalsy()
|
|
309
309
|
})
|
|
310
310
|
|
|
311
311
|
it('should include isMiniPayRecipient in send_amount_continue analytics', async () => {
|
|
@@ -2,6 +2,7 @@ import Clipboard from '@react-native-clipboard/clipboard'
|
|
|
2
2
|
import { act, fireEvent, render, waitFor } from '@testing-library/react-native'
|
|
3
3
|
import * as React from 'react'
|
|
4
4
|
import { Provider } from 'react-redux'
|
|
5
|
+
import Share from 'react-native-share'
|
|
5
6
|
import AppAnalytics from 'src/analytics/AppAnalytics'
|
|
6
7
|
import { SendEvents } from 'src/analytics/Events'
|
|
7
8
|
import { SendOrigin } from 'src/analytics/types'
|
|
@@ -243,6 +244,7 @@ describe('SendSelectRecipient', () => {
|
|
|
243
244
|
forceTokenId: undefined,
|
|
244
245
|
recipient: expect.any(Object),
|
|
245
246
|
origin: SendOrigin.AppSendFlow,
|
|
247
|
+
isMiniPayRecipient: false,
|
|
246
248
|
})
|
|
247
249
|
})
|
|
248
250
|
it('navigates to send amount when address recipient is pressed', async () => {
|
|
@@ -280,6 +282,7 @@ describe('SendSelectRecipient', () => {
|
|
|
280
282
|
forceTokenId: undefined,
|
|
281
283
|
recipient: expect.any(Object),
|
|
282
284
|
origin: SendOrigin.AppSendFlow,
|
|
285
|
+
isMiniPayRecipient: false,
|
|
283
286
|
})
|
|
284
287
|
})
|
|
285
288
|
|
|
@@ -349,6 +352,77 @@ describe('SendSelectRecipient', () => {
|
|
|
349
352
|
expect(getByTestId('SendOrInviteButton')).toBeTruthy()
|
|
350
353
|
})
|
|
351
354
|
|
|
355
|
+
it('opens the platform share sheet and tracks the press analytic before awaiting when inviting an unverified phone number', async () => {
|
|
356
|
+
const shareUrl = 'https://example.test/invite'
|
|
357
|
+
jest.mocked(getAppConfig).mockReturnValue({
|
|
358
|
+
displayName: 'Test App',
|
|
359
|
+
deepLinkUrlScheme: 'testapp',
|
|
360
|
+
registryName: 'test',
|
|
361
|
+
experimental: {
|
|
362
|
+
phoneNumberVerification: true,
|
|
363
|
+
inviteFriends: { shareUrl },
|
|
364
|
+
},
|
|
365
|
+
})
|
|
366
|
+
jest
|
|
367
|
+
.mocked(getRecipientVerificationStatus)
|
|
368
|
+
.mockReturnValue(RecipientVerificationStatus.UNVERIFIED)
|
|
369
|
+
|
|
370
|
+
let resolveShare!: (value: {
|
|
371
|
+
success: boolean
|
|
372
|
+
dismissedAction: boolean
|
|
373
|
+
message: string
|
|
374
|
+
}) => void
|
|
375
|
+
const sharePromise = new Promise<{
|
|
376
|
+
success: boolean
|
|
377
|
+
dismissedAction: boolean
|
|
378
|
+
message: string
|
|
379
|
+
}>((resolve) => {
|
|
380
|
+
resolveShare = resolve
|
|
381
|
+
})
|
|
382
|
+
jest.mocked(Share.open).mockReturnValueOnce(sharePromise)
|
|
383
|
+
|
|
384
|
+
const store = createMockStore(storeWithPhoneVerified)
|
|
385
|
+
|
|
386
|
+
const { getByTestId } = render(
|
|
387
|
+
<Provider store={store}>
|
|
388
|
+
<SendSelectRecipient {...mockScreenProps({})} />
|
|
389
|
+
</Provider>
|
|
390
|
+
)
|
|
391
|
+
|
|
392
|
+
const searchInput = getByTestId('SendSelectRecipientSearchInput')
|
|
393
|
+
await act(() => {
|
|
394
|
+
fireEvent.changeText(searchInput, mockE164Number2Invite)
|
|
395
|
+
})
|
|
396
|
+
await act(() => {
|
|
397
|
+
fireEvent.press(getByTestId('RecipientItem'))
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
const button = getByTestId('SendOrInviteButton')
|
|
401
|
+
expect(button).toHaveTextContent('sendSelectRecipient.buttons.invite', { exact: false })
|
|
402
|
+
|
|
403
|
+
await act(() => {
|
|
404
|
+
fireEvent.press(button)
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
// Analytics fires synchronously on tap, before the share sheet resolves
|
|
408
|
+
expect(AppAnalytics.track).toHaveBeenCalledWith(SendEvents.send_select_recipient_invite_press, {
|
|
409
|
+
recipientType: RecipientType.PhoneNumber,
|
|
410
|
+
})
|
|
411
|
+
expect(Share.open).toHaveBeenCalledWith(
|
|
412
|
+
expect.objectContaining({
|
|
413
|
+
message: expect.stringContaining(shareUrl),
|
|
414
|
+
url: shareUrl,
|
|
415
|
+
failOnCancel: false,
|
|
416
|
+
})
|
|
417
|
+
)
|
|
418
|
+
expect(navigate).not.toHaveBeenCalled()
|
|
419
|
+
|
|
420
|
+
await act(async () => {
|
|
421
|
+
resolveShare({ success: true, dismissedAction: false, message: '' })
|
|
422
|
+
await sharePromise
|
|
423
|
+
})
|
|
424
|
+
})
|
|
425
|
+
|
|
352
426
|
it('shows unknown address info text when searching for unknown address after making address verification request', async () => {
|
|
353
427
|
jest
|
|
354
428
|
.mocked(getRecipientVerificationStatus)
|
|
@@ -522,6 +596,54 @@ describe('SendSelectRecipient', () => {
|
|
|
522
596
|
recipientType: 'PhoneNumber',
|
|
523
597
|
},
|
|
524
598
|
origin: SendOrigin.AppSendFlow,
|
|
599
|
+
isMiniPayRecipient: false,
|
|
600
|
+
})
|
|
601
|
+
})
|
|
602
|
+
it('navigates to send amount with isMiniPayRecipient when address is verified by minipay', async () => {
|
|
603
|
+
jest
|
|
604
|
+
.mocked(getRecipientVerificationStatus)
|
|
605
|
+
.mockReturnValue(RecipientVerificationStatus.VERIFIED)
|
|
606
|
+
|
|
607
|
+
const store = createMockStore({
|
|
608
|
+
...storeWithPhoneVerified,
|
|
609
|
+
identity: {
|
|
610
|
+
secureSendPhoneNumberMapping: {
|
|
611
|
+
[mockE164Number3]: { addressValidationType: AddressValidationType.NONE },
|
|
612
|
+
},
|
|
613
|
+
e164NumberToAddress: { [mockE164Number3]: [mockAccount3] },
|
|
614
|
+
addressToVerifiedBy: { [mockAccount3]: 'minipay' },
|
|
615
|
+
},
|
|
616
|
+
})
|
|
617
|
+
|
|
618
|
+
const { getByTestId } = render(
|
|
619
|
+
<Provider store={store}>
|
|
620
|
+
<SendSelectRecipient {...mockScreenProps({})} />
|
|
621
|
+
</Provider>
|
|
622
|
+
)
|
|
623
|
+
const searchInput = getByTestId('SendSelectRecipientSearchInput')
|
|
624
|
+
|
|
625
|
+
await act(() => {
|
|
626
|
+
fireEvent.changeText(searchInput, mockE164Number3)
|
|
627
|
+
})
|
|
628
|
+
await act(() => {
|
|
629
|
+
fireEvent.press(getByTestId('RecipientItem'))
|
|
630
|
+
})
|
|
631
|
+
await act(() => {
|
|
632
|
+
fireEvent.press(getByTestId('SendOrInviteButton'))
|
|
633
|
+
})
|
|
634
|
+
|
|
635
|
+
expect(navigate).toHaveBeenCalledWith(Screens.SendEnterAmount, {
|
|
636
|
+
isFromScan: false,
|
|
637
|
+
defaultTokenIdOverride: undefined,
|
|
638
|
+
forceTokenId: undefined,
|
|
639
|
+
recipient: {
|
|
640
|
+
address: mockAccount3,
|
|
641
|
+
displayNumber: '(415) 555-0123',
|
|
642
|
+
e164PhoneNumber: mockE164Number3,
|
|
643
|
+
recipientType: 'PhoneNumber',
|
|
644
|
+
},
|
|
645
|
+
origin: SendOrigin.AppSendFlow,
|
|
646
|
+
isMiniPayRecipient: true,
|
|
525
647
|
})
|
|
526
648
|
})
|
|
527
649
|
it('navigates to secure send flow when phone number recipient with multiple addresses, first time seeing it', async () => {
|
|
@@ -631,6 +753,7 @@ describe('SendSelectRecipient', () => {
|
|
|
631
753
|
recipientType: 'PhoneNumber',
|
|
632
754
|
},
|
|
633
755
|
origin: SendOrigin.AppSendFlow,
|
|
756
|
+
isMiniPayRecipient: false,
|
|
634
757
|
})
|
|
635
758
|
})
|
|
636
759
|
it.each([{ searchAddress: mockAccount2 }, { searchAddress: mockAccount3 }])(
|
|
@@ -694,6 +817,7 @@ describe('SendSelectRecipient', () => {
|
|
|
694
817
|
thumbnailPath: undefined,
|
|
695
818
|
},
|
|
696
819
|
origin: SendOrigin.AppSendFlow,
|
|
820
|
+
isMiniPayRecipient: false,
|
|
697
821
|
})
|
|
698
822
|
}
|
|
699
823
|
)
|
|
@@ -759,6 +883,7 @@ describe('SendSelectRecipient', () => {
|
|
|
759
883
|
thumbnailPath: undefined,
|
|
760
884
|
},
|
|
761
885
|
origin: SendOrigin.AppSendFlow,
|
|
886
|
+
isMiniPayRecipient: false,
|
|
762
887
|
})
|
|
763
888
|
}
|
|
764
889
|
)
|
|
@@ -4,7 +4,7 @@ import { useTranslation } from 'react-i18next'
|
|
|
4
4
|
import { StyleSheet, Text, View } from 'react-native'
|
|
5
5
|
import { getFontScaleSync } from 'react-native-device-info'
|
|
6
6
|
import { SafeAreaView } from 'react-native-safe-area-context'
|
|
7
|
-
import Share
|
|
7
|
+
import Share from 'react-native-share'
|
|
8
8
|
import { isAddressFormat } from 'src/account/utils'
|
|
9
9
|
import AppAnalytics from 'src/analytics/AppAnalytics'
|
|
10
10
|
import { SendEvents } from 'src/analytics/Events'
|
|
@@ -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
|
|
|
@@ -323,22 +326,24 @@ function SendSelectRecipient({ route }: Props) {
|
|
|
323
326
|
// Invites
|
|
324
327
|
if (shouldInviteRecipient) {
|
|
325
328
|
if (!shareUrl) {
|
|
326
|
-
Logger.warn('SendSelectRecipient', 'No share URL found for invite
|
|
329
|
+
Logger.warn('SendSelectRecipient', 'No share URL found for invite')
|
|
327
330
|
return
|
|
328
331
|
}
|
|
329
332
|
|
|
330
|
-
const shareOptions: ShareSingleOptions = {
|
|
331
|
-
social: Social.Sms,
|
|
332
|
-
recipient: recipient.e164PhoneNumber,
|
|
333
|
-
message: t('inviteWithSmsMessage.shareMessage', { shareUrl }),
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
await Share.shareSingle(shareOptions)
|
|
337
|
-
|
|
338
333
|
AppAnalytics.track(SendEvents.send_select_recipient_invite_press, {
|
|
339
334
|
recipientType: recipient.recipientType,
|
|
340
335
|
})
|
|
341
336
|
|
|
337
|
+
try {
|
|
338
|
+
await Share.open({
|
|
339
|
+
message: t('inviteWithSmsMessage.shareMessage', { shareUrl }),
|
|
340
|
+
url: shareUrl,
|
|
341
|
+
failOnCancel: false,
|
|
342
|
+
})
|
|
343
|
+
} catch (error) {
|
|
344
|
+
Logger.warn('SendSelectRecipient', 'Share sheet failed', error)
|
|
345
|
+
}
|
|
346
|
+
|
|
342
347
|
return
|
|
343
348
|
}
|
|
344
349
|
|
|
@@ -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
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useTranslation } from 'react-i18next'
|
|
1
2
|
import { BooleanFilterChip } from 'src/components/FilterChipsCarousel'
|
|
2
3
|
import { getDynamicConfigParams } from 'src/statsig'
|
|
3
4
|
import { DynamicConfigs } from 'src/statsig/constants'
|
|
@@ -18,6 +19,8 @@ export default function useSendFilterChips({
|
|
|
18
19
|
filterChips: BooleanFilterChip<TokenBalance>[]
|
|
19
20
|
defaultToken: TokenBalance | undefined
|
|
20
21
|
} {
|
|
22
|
+
const { t } = useTranslation()
|
|
23
|
+
|
|
21
24
|
const { miniPayTokenIds: configTokenIds } = getDynamicConfigParams(
|
|
22
25
|
DynamicConfigs[StatsigDynamicConfigs.SEND_CONFIG]
|
|
23
26
|
)
|
|
@@ -27,7 +30,7 @@ export default function useSendFilterChips({
|
|
|
27
30
|
? [
|
|
28
31
|
{
|
|
29
32
|
id: 'minipay',
|
|
30
|
-
name: '
|
|
33
|
+
name: t('sendEnterAmountScreen.miniPayFilterChip'),
|
|
31
34
|
filterFn: (token: TokenBalance) => miniPayTokenIds.includes(token.tokenId),
|
|
32
35
|
isSelected: true,
|
|
33
36
|
},
|