Skip to content

Commit b59db9b

Browse files
authored
fix: resolve Keystone QR scan button doing nothing (#1027)
* fix: resolve Keystone QR scan button doing nothing ConnectKeystoneStartScreen navigated to ScanQrCode at the root stack level, but the Add New Account screen is a transparentModal — so the scanner rendered behind the modal. Navigate to KeystoneNavigator within AddNewAccountNavigator instead, matching the Ledger flow pattern. * refactor: extract shared KeystoneStackParamList, fix import order Consolidate duplicated KeystoneStackParamList into a shared keystoneNavigatorTypes.ts (matching Ledger pattern). Type the createStackNavigator call. Fix eslint import/order violations.
1 parent e280ee9 commit b59db9b

File tree

7 files changed

+21
-29
lines changed

7 files changed

+21
-29
lines changed

src/features/keystone/ConnectKeystoneStartScreen.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import { useOpacity, useSpacing } from '@theme/themeHooks'
2020
import useBackHandler from '@hooks/useBackHandler'
2121
import { useTheme } from '@shopify/restyle'
2222
import { t } from 'i18next'
23-
import { RootNavigationProp } from 'src/navigation/rootTypes'
2423
import { Image, Linking, Platform } from 'react-native'
24+
import { AddNewAccountNavigationProp } from '../home/addNewAccount/addNewAccountTypes'
2525

2626
type CameraPermissionBottomSheetAlertRef = {
2727
show: () => void
@@ -127,14 +127,14 @@ const ConnectKeystoneStart = () => {
127127
const { hasPermission } = useCamera()
128128
const cameraPermissionBottomSheetAlertRef =
129129
useRef<CameraPermissionBottomSheetAlertRef>(null)
130-
const rootNav = useNavigation<RootNavigationProp>()
130+
const navigation = useNavigation<AddNewAccountNavigationProp>()
131131
const handleStart = useCallback(() => {
132132
if (!hasPermission) {
133133
cameraPermissionBottomSheetAlertRef.current?.show()
134134
} else {
135-
rootNav.navigate('ScanQrCode')
135+
navigation.navigate('KeystoneNavigator')
136136
}
137-
}, [rootNav, hasPermission])
137+
}, [navigation, hasPermission])
138138
return (
139139
<SafeAreaBox
140140
flex={1}

src/features/keystone/KeystoneNavigator.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { createStackNavigator } from '@react-navigation/stack'
33
import ScanQrCode from './ScanQrCodeScreen'
44
import SelectKeystoneAccountsScreen from './SelectKeystoneAccountsScreen'
55
import KeystoneAccountAssignScreen from './KeystoneAccountAssignScreen'
6+
import { KeystoneStackParamList } from './keystoneNavigatorTypes'
67

7-
const KeystoneStack = createStackNavigator()
8+
const KeystoneStack = createStackNavigator<KeystoneStackParamList>()
89

910
const KeystoneNavigator = () => {
1011
return (

src/features/keystone/ScanQrCodeScreen.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import DynamicQrScanner from '@components/DynamicQrScanner'
33
import SafeAreaBox from '@components/SafeAreaBox'
44
import { URDecoder } from '@ngraveio/bc-ur'
55
import KeystoneSDK, { MultiAccounts, UR } from '@keystonehq/keystone-sdk'
6-
import { RootNavigationProp } from 'src/navigation/rootTypes'
76
import { useNavigation } from '@react-navigation/native'
87
import { Alert } from 'react-native'
98
import { useTranslation } from 'react-i18next'
109
import { KeystoneAccountType } from './SelectKeystoneAccountsScreen'
10+
import { KeystoneNavigationProp } from './keystoneNavigatorTypes'
1111

1212
const ScanQrCodeScreen = () => {
1313
const { t } = useTranslation()
14-
const navigation = useNavigation<RootNavigationProp>()
14+
const navigation = useNavigation<KeystoneNavigationProp>()
1515
const [multiAccounts, setMultiAccounts] = useState<MultiAccounts>()
1616
const decoder = useMemo(() => new URDecoder(), [])
1717
const [isScanQrCodeComplete, setIsScanQrCodeComplete] = useState(false)

src/features/keystone/SelectKeystoneAccountsScreen.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ import TouchableContainer from '@components/TouchableContainer'
1212
import { humanReadable } from '@helium/spl-utils'
1313
import BN from 'bn.js'
1414
import { RouteProp, useNavigation, useRoute } from '@react-navigation/native'
15-
import {
16-
RootNavigationProp,
17-
RootStackParamList,
18-
} from 'src/navigation/rootTypes'
15+
import { RootNavigationProp } from 'src/navigation/rootTypes'
1916
import { useAccountStorage } from '@storage/AccountStorageProvider'
2017
import { ellipsizeAddress } from '@utils/accountUtils'
2118
import base58 from 'bs58'
@@ -24,6 +21,7 @@ import { PublicKey } from '@solana/web3.js'
2421
import { useTranslation } from 'react-i18next'
2522
import { useSolana } from '../../solana/SolanaProvider'
2623
import { useKeystoneOnboarding } from './KeystoneOnboardingProvider'
24+
import { KeystoneStackParamList } from './keystoneNavigatorTypes'
2725

2826
export type KeystoneAccountType = {
2927
path: string
@@ -34,7 +32,7 @@ export type KeystoneAccountType = {
3432
}
3533

3634
type SelectKeystoneAccountsScreenRouteProp = RouteProp<
37-
RootStackParamList,
35+
KeystoneStackParamList,
3836
'SelectKeystoneAccounts'
3937
>
4038

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { StackNavigationProp } from '@react-navigation/stack'
2+
import { KeystoneAccountType } from './SelectKeystoneAccountsScreen'
3+
4+
export type KeystoneStackParamList = {
5+
ScanQrCode: undefined
6+
SelectKeystoneAccounts: { derivationAccounts: KeystoneAccountType[] }
7+
KeystoneAccountAssignScreen: undefined
8+
}
9+
10+
export type KeystoneNavigationProp = StackNavigationProp<KeystoneStackParamList>

src/navigation/RootNavigator.tsx

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import { useAsyncCallback } from 'react-async-hook'
1818
import changeNavigationBarColor from 'react-native-navigation-bar-color'
1919
import Toast from 'react-native-simple-toast'
2020
import { useSelector } from 'react-redux'
21-
import ScanQrCodeScreen from '../features/keystone/ScanQrCodeScreen'
22-
import SelectKeystoneAccountsScreen from '../features/keystone/SelectKeystoneAccountsScreen'
2321
import ConnectedWallets, {
2422
ConnectedWalletsRef,
2523
} from '../features/account/ConnectedWallets'
@@ -181,18 +179,6 @@ const RootNavigator = () => {
181179
component={ImportPrivateKey}
182180
options={screenOptions}
183181
/>
184-
<RootStack.Screen
185-
name="SelectKeystoneAccounts"
186-
component={SelectKeystoneAccountsScreen}
187-
options={{
188-
headerShown: false,
189-
}}
190-
/>
191-
<RootStack.Screen
192-
name="ScanQrCode"
193-
component={ScanQrCodeScreen}
194-
options={screenOptions}
195-
/>
196182
</RootStack.Navigator>
197183
</ConnectedWallets>
198184
)

src/navigation/rootTypes.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { LinkWalletRequest, SignHotspotRequest } from '@helium/wallet-link'
22
import { StackNavigationProp } from '@react-navigation/stack'
3-
import { KeystoneAccountType } from 'src/features/keystone/SelectKeystoneAccountsScreen'
43
import { PaymentRouteParam } from '../features/home/homeTypes'
54

65
export type RootStackParamList = {
@@ -12,8 +11,6 @@ export type RootStackParamList = {
1211
RequestScreen: undefined
1312
DappLoginScreen: { uri: string; callback: string }
1413
ImportPrivateKey: { key?: string }
15-
SelectKeystoneAccounts: { derivationAccounts: KeystoneAccountType[] }
16-
ScanQrCode: undefined
1714
}
1815

1916
export type TabBarStackParamList = {

0 commit comments

Comments
 (0)