Skip to content

Commit 0bc724f

Browse files
authored
Merge branch 'main' into @szymon/nativeCryptoLib
2 parents 4816040 + 3f67c48 commit 0bc724f

File tree

15 files changed

+635
-194
lines changed

15 files changed

+635
-194
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* This is the whitelist of deeplinks that are allowed to be opened in the app
3+
* It is used to prevent malicious deeplinks from being opened in the app
4+
* It is also used to prevent deeplinks from being opened in the app that are not allowed
5+
**/
6+
export const DEEPLINK_WHITELIST = [
7+
'core://solanaLaunch',
8+
'core://stakecomplete',
9+
'core://watchlist',
10+
'core://portfolio',
11+
'core://onrampcompleted',
12+
'core://offrampcompleted',
13+
'core://receive',
14+
'core://trackTokenDetail',
15+
'core://track',
16+
'core://meld/onramp',
17+
'core://meld/offramp',
18+
'core://stake',
19+
'core://claimStakeReward',
20+
'core://addStake',
21+
'core://discoverCollectibles',
22+
'core://collectibleManagement',
23+
'core://tokenManagement',
24+
'core://send',
25+
'core://swap',
26+
'core://walletConnectScan',
27+
'core://activity',
28+
'core://browser',
29+
'core://browser/tabs',
30+
'core://browser/history',
31+
'core://accountSettings',
32+
'core://accountSettings/selectCurrency',
33+
'core://accountSettings/selectAppearance',
34+
'core://accountSettings/securityAndPrivacy',
35+
'core://accountSettings/connectedSites',
36+
'core://accountSettings/changePin',
37+
'core://accountSettings/manageAccounts',
38+
'core://accountSettings/manageNetworks',
39+
'core://accountSettings/addressBook',
40+
'core://accountSettings/selectAvatar',
41+
'core://accountSettings/notificationPreferences',
42+
'core://accountSettings/importWallet',
43+
'core://accountSettings/importPrivateKey',
44+
'core://accountSettings/importSeedWallet'
45+
]

packages/core-mobile/app/contexts/DeeplinkContext/utils/handleDeeplink.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ import { dismissMeldStack } from 'features/meld/utils'
1111
import { offrampSend } from 'store/meld/slice'
1212
import { closeInAppBrowser } from 'utils/openInAppBrowser'
1313
import { ACTIONS, DeepLink, PROTOCOLS } from '../types'
14+
import { DEEPLINK_WHITELIST } from '../consts'
15+
16+
const lowercasedDeeplinkWhitelist = DEEPLINK_WHITELIST.map(url =>
17+
url.toLowerCase()
18+
)
1419

1520
export const handleDeeplink = ({
1621
deeplink,
@@ -74,6 +79,11 @@ export const handleDeeplink = ({
7479
closeInAppBrowser()
7580
dismissMeldStack(action, searchParams)
7681
} else {
82+
const baseUrl = deeplink.url.split('?')[0]?.toLowerCase()
83+
if (baseUrl && !lowercasedDeeplinkWhitelist.includes(baseUrl)) {
84+
Logger.warn(`${deeplink.url} is not allowed to be opened in the app`)
85+
return
86+
}
7787
const path = deeplink.url.split(':/')[1]
7888
path && navigateFromDeeplinkUrl(path)
7989
}

packages/core-mobile/app/new/common/components/TokenInputWidget.tsx

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export const TokenInputWidget = ({
4242
sx,
4343
disabled,
4444
editable = true,
45-
inputTextColor,
4645
isLoadingAmount = false,
47-
autoFocus
46+
autoFocus,
47+
valid = true
4848
}: {
4949
title: string
5050
amount?: bigint
@@ -61,9 +61,9 @@ export const TokenInputWidget = ({
6161
sx?: SxProp
6262
disabled?: boolean
6363
editable?: boolean
64-
inputTextColor?: string
6564
isLoadingAmount?: boolean
6665
autoFocus?: boolean
66+
valid?: boolean
6767
// eslint-disable-next-line sonarjs/cognitive-complexity
6868
}): JSX.Element => {
6969
const {
@@ -177,21 +177,24 @@ export const TokenInputWidget = ({
177177
alignItems: 'center',
178178
gap: 24
179179
}}>
180-
<View sx={{ flexDirection: 'row', alignItems: 'center', gap: 12 }}>
180+
<View
181+
sx={{
182+
flexDirection: 'row',
183+
alignItems: 'flex-start',
184+
gap: 12
185+
}}>
181186
{token && network && (
182187
<LogoWithNetwork
183188
token={token}
184189
network={network}
185190
outerBorderColor={colors.$surfaceSecondary}
186191
/>
187192
)}
188-
<View sx={{ flex: 1 }}>
193+
<View sx={{ flex: 1, justifyContent: 'space-between' }}>
189194
<View
190195
sx={{
191196
flexDirection: 'row',
192-
alignItems: 'center',
193-
gap: 10,
194-
justifyContent: 'space-between'
197+
gap: 8
195198
}}>
196199
<TouchableOpacity
197200
accessible={true}
@@ -224,7 +227,9 @@ export const TokenInputWidget = ({
224227
<View
225228
sx={{
226229
alignItems: 'flex-end',
227-
flex: 1
230+
justifyContent: 'center',
231+
flex: 1,
232+
minHeight: 50
228233
}}
229234
pointerEvents={token === undefined ? 'none' : 'auto'}>
230235
{editable ? (
@@ -236,31 +241,22 @@ export const TokenInputWidget = ({
236241
autoFocus={autoFocus}
237242
editable={editable}
238243
denomination={token?.decimals ?? 0}
239-
style={{
240-
fontFamily: 'Aeonik-Medium',
241-
fontSize: 42,
242-
minWidth: 100,
243-
width: '100%',
244-
textAlign: 'right',
245-
marginRight: Platform.OS === 'android' ? -4 : 0,
246-
color:
247-
inputTextColor ??
248-
(editable
249-
? colors.$textPrimary
250-
: colors.$textSecondary)
251-
}}
244+
textAlign="right"
245+
valid={valid}
252246
value={amount}
253247
onChange={handleAmountChange}
254248
onFocus={handleFocus}
255249
onBlur={handleBlur}
256250
placeholder="0.00"
251+
style={{
252+
marginBottom: 8
253+
}}
257254
/>
258255
) : (
259256
<View
260257
style={{
261-
height: 50,
262258
width: '100%',
263-
justifyContent: 'flex-end'
259+
marginBottom: Platform.OS === 'ios' ? 12 : 0
264260
}}>
265261
<Text
266262
adjustsFontSizeToFit
@@ -269,15 +265,15 @@ export const TokenInputWidget = ({
269265
fontFamily: 'Aeonik-Medium',
270266
fontSize: 42,
271267
lineHeight: 42,
272-
minHeight: 42,
273268
width: '100%',
274269
textAlign: 'right',
275270
color: !amount
276271
? alpha(colors.$textSecondary, 0.2)
277-
: inputTextColor ??
278-
(editable
279-
? colors.$textPrimary
280-
: colors.$textSecondary)
272+
: !valid
273+
? colors.$textDanger
274+
: editable
275+
? colors.$textPrimary
276+
: colors.$textSecondary
281277
}}>
282278
{nonEditableInputValue}
283279
</Text>
@@ -292,7 +288,7 @@ export const TokenInputWidget = ({
292288
alignItems: 'center',
293289
gap: 24,
294290
justifyContent: 'space-between',
295-
marginTop: Platform.OS === 'android' && editable ? -14 : -4
291+
marginTop: -12
296292
}}>
297293
<View>
298294
{token &&
@@ -315,15 +311,20 @@ export const TokenInputWidget = ({
315311
sx={{
316312
flexDirection: 'row',
317313
alignItems: 'center',
318-
gap: 6,
319314
flexShrink: 1
320315
}}>
321-
{isLoadingAmount && <ActivityIndicator size="small" />}
316+
{isLoadingAmount && (
317+
<View>
318+
<View style={{ position: 'absolute', right: 6, top: -8 }}>
319+
<ActivityIndicator size="small" />
320+
</View>
321+
</View>
322+
)}
322323
<Text
323324
variant="subtitle2"
324325
numberOfLines={1}
325326
sx={{
326-
color: inputTextColor ?? '$textSecondary'
327+
color: valid ? colors.$textSecondary : colors.$textDanger
327328
}}>
328329
{formatInCurrency(amount)}
329330
</Text>

packages/core-mobile/app/new/features/activity/components/ActivityList.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1+
import {
2+
isTokenWithBalanceAVM,
3+
isTokenWithBalancePVM
4+
} from '@avalabs/avalanche-module'
15
import { BridgeTransfer } from '@avalabs/bridge-unified'
26
import { BridgeTransaction } from '@avalabs/core-bridge-sdk'
37
import { Text, useTheme, View } from '@avalabs/k2-alpine'
8+
import { TokenWithBalance } from '@avalabs/vm-module-types'
49
import { FlashListProps, ListRenderItem } from '@shopify/flash-list'
510
import { CollapsibleTabs } from 'common/components/CollapsibleTabs'
611
import { isXpTransaction } from 'common/utils/isXpTransactions'
712
import { ACTIVITY_LIST_ITEM_HEIGHT } from 'features/portfolio/assets/components/ActivityListItem'
813
import { PendingBridgeTransactionItem } from 'features/portfolio/assets/components/PendingBridgeTransactionItem'
914
import { TokenActivityListItem } from 'features/portfolio/assets/components/TokenActivityListItem'
1015
import { XpActivityListItem } from 'features/portfolio/assets/components/XpActivityListItem'
16+
import { useWatchlist } from 'hooks/watchlist/useWatchlist'
1117
import React, { useCallback } from 'react'
12-
import { TokenWithBalance } from '@avalabs/vm-module-types'
13-
import {
14-
isTokenWithBalanceAVM,
15-
isTokenWithBalancePVM
16-
} from '@avalabs/avalanche-module'
1718
import { ActivityListItem } from '../utils'
1819

1920
export const ActivityList = ({
@@ -37,6 +38,7 @@ export const ActivityList = ({
3738
renderHeader: () => React.ReactNode
3839
renderEmpty: () => React.ReactNode
3940
}): JSX.Element => {
41+
const { prices } = useWatchlist()
4042
const renderItem: ListRenderItem<ActivityListItem> = useCallback(
4143
({ item, index }) => {
4244
if (item.type === 'header') {
@@ -97,6 +99,7 @@ export const ActivityList = ({
9799
key={xpToken?.symbol}
98100
overrideProps={overrideProps}
99101
data={data}
102+
extraData={{ prices }}
100103
renderItem={renderItem}
101104
ListHeaderComponent={renderHeader}
102105
ListEmptyComponent={renderEmpty}

packages/core-mobile/app/new/features/bridge/screens/BridgeScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ export const BridgeScreen = (): JSX.Element => {
440440
onBlur={() => setIsInputFocused(false)}
441441
onSelectToken={handleSelectToken}
442442
maximum={maximum}
443-
inputTextColor={errorMessage ? colors.$textDanger : undefined}
443+
valid={!errorMessage}
444444
/>
445445
</Animated.View>
446446
)

packages/core-mobile/app/new/features/meld/hooks/useSelectAmount.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,6 @@ export const useSelectAmount = ({
370370
sx={{
371371
flexDirection: 'row',
372372
justifyContent: 'center',
373-
marginBottom: 8,
374373
color:
375374
errorMessage === undefined
376375
? alpha(colors.$textPrimary, 0.9)

packages/core-mobile/app/new/features/swap/screens/SwapScreen.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export const SwapScreen = (): JSX.Element => {
430430
onBlur={() => setIsInputFocused(false)}
431431
onSelectToken={handleSelectFromToken}
432432
maximum={fromToken?.balance}
433-
inputTextColor={localError ? theme.colors.$textDanger : undefined}
433+
valid={!localError}
434434
/>
435435
</View>
436436
)
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import React, { useState } from 'react'
2+
import { Platform } from 'react-native'
3+
import { ScrollView, Text, View } from '../Primitives'
4+
import { AutoSizeTextInput } from './AutoSizeTextInput'
5+
6+
export default {
7+
title: 'AutoSizeTextInput'
8+
}
9+
10+
export const All = (): JSX.Element => {
11+
const [value, setValue] = useState('107.25')
12+
13+
return (
14+
<ScrollView
15+
sx={{
16+
width: '100%'
17+
}}
18+
contentContainerStyle={{ padding: 16, paddingHorizontal: 16, gap: 32 }}>
19+
<View sx={{ gap: 16, width: '100%' }}>
20+
<Text variant="heading6">
21+
AutoSizeTextInput with initial font size 60
22+
</Text>
23+
<AutoSizeTextInput
24+
value={value}
25+
onChangeText={setValue}
26+
initialFontSize={60}
27+
placeholder="0.00"
28+
keyboardType={Platform.OS === 'ios' ? 'numeric' : undefined}
29+
inputMode={Platform.OS === 'android' ? 'numeric' : undefined}
30+
/>
31+
</View>
32+
<View sx={{ gap: 16, width: '100%' }}>
33+
<Text variant="heading6">AutoSizeTextInput</Text>
34+
<AutoSizeTextInput
35+
value={value}
36+
onChangeText={setValue}
37+
placeholder="0.00"
38+
keyboardType={Platform.OS === 'ios' ? 'numeric' : undefined}
39+
inputMode={Platform.OS === 'android' ? 'numeric' : undefined}
40+
/>
41+
</View>
42+
<View sx={{ gap: 16, width: '100%' }}>
43+
<Text variant="heading6">AutoSizeTextInput with prefix</Text>
44+
<AutoSizeTextInput
45+
value={value}
46+
prefix="$"
47+
placeholder="$0.00"
48+
onChangeText={setValue}
49+
keyboardType={Platform.OS === 'ios' ? 'numeric' : undefined}
50+
inputMode={Platform.OS === 'android' ? 'numeric' : undefined}
51+
/>
52+
</View>
53+
<View sx={{ gap: 16, width: '100%' }}>
54+
<Text variant="heading6">AutoSizeTextInput with suffix</Text>
55+
<AutoSizeTextInput
56+
value={value}
57+
suffix="AVAX"
58+
suffixSx={{
59+
marginBottom: 20
60+
}}
61+
placeholder="0.00"
62+
onChangeText={setValue}
63+
keyboardType={Platform.OS === 'ios' ? 'numeric' : undefined}
64+
inputMode={Platform.OS === 'android' ? 'numeric' : undefined}
65+
/>
66+
</View>
67+
<View sx={{ gap: 16, width: '100%' }}>
68+
<Text variant="heading6">
69+
AutoSizeTextInput with renderRight as suffix
70+
</Text>
71+
<AutoSizeTextInput
72+
value={value}
73+
suffix="AVAX"
74+
placeholder="0.00"
75+
onChangeText={setValue}
76+
keyboardType={Platform.OS === 'ios' ? 'numeric' : undefined}
77+
inputMode={Platform.OS === 'android' ? 'numeric' : undefined}
78+
/>
79+
</View>
80+
<View sx={{ gap: 16, width: '100%' }}>
81+
<Text variant="heading6">AutoSizeTextInput with textAlign="right"</Text>
82+
<AutoSizeTextInput
83+
value={value}
84+
textAlign="right"
85+
style={{}}
86+
placeholder="0.00"
87+
onChangeText={setValue}
88+
keyboardType={Platform.OS === 'ios' ? 'numeric' : undefined}
89+
inputMode={Platform.OS === 'android' ? 'numeric' : undefined}
90+
/>
91+
</View>
92+
</ScrollView>
93+
)
94+
}

0 commit comments

Comments
 (0)